Direct access to gallery files from gallery template ?

7 years 1 month ago #291842 by rbuelund
I have created a custom template for the CB gallery plugin. Inside the template I need direct access to the profile gallery image folder (/images/comprofiler/plug_cbgallery/user_id/photos) - I use the direct path in the items.php file to generate som specific thumbnails.

but every time a new gallery is created a .htaccess file is created automatically in the /images/comprofiler/plug_cbgallery folder, which blocks the access to the subfolders from the items.php file in the template - how can I disable this or can I access the images files in some other way inside the items.php file?

Please Log in to join the conversation.

7 years 1 month ago #291863 by krileon
You can not access CB Gallery files directly. It deliberately protects direct access. You have to route through CB Gallery. To generate the URL you need the gallery entry and the gallery object. You can then generate it using the below, which handles both internal and external usages.

if ( $row->domain() ) {
	$showPath				=	htmlspecialchars( $row->path() );
} else {
	$showPath				=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'item', 'func' => 'show', 'id' => $row->get( 'id', 0, GetterInterface::INT ), 'gallery' => $gallery->id() ), 'raw', 0, true );
}

$row being the gallery entry and $gallery being the gallery object. Both are available in $items.php (assuming you're acting inside of the foreach loop for $rows).


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

7 years 1 month ago #291913 by rbuelund
Hmmm.. if I insert the code in the foreach loop in the function showItems in items.php I get theese errors:


Notice: Undefined variable: _CB_framework in /home/xxxxxx/www/components/com_comprofiler/plugin/user/plug_cbgallery/templates/xxxxxx/items.php on line 69

Fatal error: Call to a member function pluginClassUrl() on a non-object in /home/xxxxxx/www/components/com_comprofiler/plugin/user/plug_cbgallery/templates/xxxxxx/items.php on line 69

Please Log in to join the conversation.

7 years 1 month ago #291927 by krileon
It's meant as an example not a direct insert and done. In this case the global isn't defined so you need to define it with the below at the top of the function.

global $_CB_framework;

Use an IDE like phpstorm or netbeans so you can see syntax errors like that directly in the code.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

7 years 1 month ago #291938 by rbuelund
Ok - got that to work! But now I need another thing. Instead of a thumbnail image for each image/file I only want the text "View" as the link to the full image. I can style the thumbnail away, but I cannot grasp where to put the text "View".
I can see that the thumbnail code is generated with the cbTooltip function in the file item_container.php around line 122 - but i cannot seem to insert the text there ??

Please Log in to join the conversation.

7 years 1 month ago - 7 years 1 month ago #291964 by krileon
The thumbnail is output in $item_container.php. Specifically the variable $embed is responsible for it. It adds the thumbnail using a modal window usage (our cbTooltip API). You'll have to replace the following inside that usage.

$row->thumbnail( $gallery, $width, ( ( $row->width( true ) >= $width ) || ( $row->height( true ) >= $width ) || ( $row->mimeType() == 'video/x-youtube' ) ) )

You can put whatever text there you want like the follow (which supports translations).

CBTxt::T( 'View' )


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.499 seconds

Facebook Twitter LinkedIn