Page 1 of 1

Re: Content block with Gallery picker

Posted: Thu May 10, 2012 2:12 pm
by manuel
Hi kernity,

Thanks for sharing this!
I was working on accomplishing the same but didn't get it to work so i searched the forum and luckily found your post! (not a single other posts on this, kind of surprises me...)

What version of the cms and Gallery module are you using?
I'm using (all the very latest):
cmsms 1.10.3
ECB 1.3
CGExtensions 1.28.2
Gallery 1.5.3

I'm asking because i get the error below when i test your UDT solution:

Code: Select all

Fatal error: Call to undefined method Gallery::_GetGalleries() in /home/cremedel/public_html/lib/classes/class.usertagoperations.inc.php(260) : eval()'d code on line 2
How did i try to accomplish it?
In gallery, create a template "selectbox" containing the following:

Code: Select all

{foreach from=$images item=image name=img}
{if $image->isdir}{$image->titlename}={$image->titlename}{if $smarty.foreach.img.last}{else},{/if}{/if}
{/foreach}
This will create the required output as specified in the ECB help file:
(test the output by putting {Gallery action='gallerytree' template='selectbox'} in the content of a page).

Code: Select all

galleryname=http://www.domain.com/gallerysomething/url/,galleryname2=http://www.domain.com/gallerysomething2/url/
The code to enter in the page template:

Code: Select all

{content_module module="ECB" field="dropdown_from_module" block="test2" label="Gallery" mod="cms_module module='Gallery' action='gallerytree' template='selectbox'"}
This generates the error below:

Code: Select all

string(122) "Smarty error: [in temporary template line 1]: syntax error: missing attribute value (Smarty_Compiler.class.php, line 1593)"
So i'm stuck with 2 perfectly workable solutions that both produce errors :'(

Greetings,
Manuel

Re: Content block with Gallery picker

Posted: Sun May 20, 2012 7:05 pm
by Jos
Hi Manuel,

Since CMSms 1.10 and Gallery 1.5, you should be able to call it with:

Code: Select all

$galleries = Gallery_utils::GetGalleries();
Also might want to check the

Code: Select all

Gallery_utils::GalleryDropdown();

Re: Content block with Gallery picker

Posted: Mon May 21, 2012 4:00 pm
by Wishbone
What I often do is make a gallery folder called 'content' .. Inside that, I create directories with the same name as the page alias. If the directory exists for that page, I call Gallery.

Re: Content block with Gallery picker

Posted: Fri Jun 15, 2012 3:28 am
by tbaalham
Just implemented this using ECB and a slightly modified UDT. Thanks to those who posted suggestions on this thread!

template code

Code: Select all

{content_module module="ECB" field="dropdown_from_module" block="gallery" label="Gallery" mod="get_gallery_list" assign="gallery_dir"}
{if isset($gallery_dir) && $gallery_dir ne ""}{Gallery dir=$gallery_dir}{/if}
get_gallery_list UDT code

Code: Select all

$galleries = Gallery_utils::GetGalleries();
$valuepairs = array();
foreach ($galleries as $gallery) {
  $gallery_dir = $gallery['filepath'].rtrim($gallery['filename'], '/');
  $valuepairs[] = $gallery_dir.'='.$gallery_dir;
}
echo implode(",",$valuepairs);

Re: Content block with Gallery picker

Posted: Fri Jun 15, 2012 3:09 pm
by willcom
Hi tbaalham,

I tried to use your code, but i get the following error: Fatal error: Class 'Gallery_utils' not found in C:\****\wwwroot\lib\classes\class.usertagoperations.inc.php(260) : eval()'d code on line 1

It seems almost like the same error as Manuel did get.

What am I doing wrong?

I use the following modules and CMS:
ECB 1.3
CGExtensions 1.29.1
Gallery 1.5.3
CMS 1.10.3

Thnx!

Re: Content block with Gallery picker

Posted: Fri Sep 14, 2012 2:07 am
by chris..
Hi there, I tried your solution with the very last versions of all modules and core:

CMSMS 1.11.1
ECB 1.3
Gallery 1.6

and every tries broke my back-end pages editing (everything go blank).

So I put the UDT code in a file named function.gls.php in my plugins folder and call it inside ECB module, and tadam!

Complete solution, waiting ECB to work correctly with UDT:

function.gls.php (plugins folder):

Code: Select all

<?php
function smarty_function_gls()
{
$galleries = Gallery_utils::GetGalleries();
$valuepairs = array();
foreach ($galleries as $gallery) {
  $gallery_dir = $gallery['filepath'].rtrim($gallery['filename'], '/');
  $valuepairs[] = $gallery_dir.'='.$gallery_dir;
}
echo implode(",",$valuepairs);
}
?>
template:

Code: Select all

{content_module module="ECB" field="dropdown_from_module" block="test2" label="Gallery" mod="gls" assign="gallery_dir" }
{if isset($gallery_dir) && $gallery_dir ne ""}{Gallery dir=$gallery_dir}
{/if}
Hope this will help (and thanks to the cmsms community, this so large brain)..

Re: Content block with Gallery picker

Posted: Thu Jan 10, 2013 3:16 pm
by manuel
Dear Wishbone,

As of version 1.4, ECB no longer supports the dropdown_from_module
I'm glad you replied too as i'm now setting up the galleries like you described earlier.
What I often do is make a gallery folder called 'content' .. Inside that, I create directories with the same name as the page alias. If the directory exists for that page, I call Gallery.
I was just wondering if this is more or less what you where doing?

Code: Select all

{Gallery dir="designers/$page_alias" assign='galleryvar'}{if $galleryvar|strstr:"exist"}no gallery{else}{$galleryvar}{/if}
Greetings,
Manuel

Re: Content block with Gallery picker

Posted: Fri Jan 11, 2013 5:31 pm
by Wishbone
Something like that.. To keep it simple and less business logic in Smarty, I would call a UDT to process everything I plan to do on that page. For the gallery I would call a file_exists on the gallery. Then I would return a variable ($data for example), and in the template, I would call:

{if isset($data.gallery){Gallery ...}{/if}

..among all my other logic checks. This keeps the template very simple, and the logic in PHP which is easier to read.

Re: Content block with Gallery picker

Posted: Fri Jan 11, 2013 7:42 pm
by manuel
Dear Wishbone,

thx for the update :)

Greetings,
Manuel

Re: Content block with Gallery picker

Posted: Wed Aug 07, 2013 6:11 am
by Cerulean
Here is the code I used for generating a gallery dropdown in case it helps someone...

UDT "get_gallery_list" - in my case I wanted to exclude the main parent gallery from the dropdown, hence the if ($gallery['filename'] != "")

Code: Select all

$galleries = Gallery_utils::GetGalleries();
$valuepairs = array();
foreach ($galleries as $gallery) {
	if ($gallery['filename'] != ""){
		$gallery_dir = $gallery['filepath'].rtrim($gallery['filename'], '/');
		$valuepairs[$gallery_dir] = $gallery_dir;
	}
}
return $valuepairs;
In the template

Code: Select all

{content_module module="ECB" field="dropdown_from_udt" block="the_gallery" label="Gallery" udt="get_gallery_list" first_value="(none)" assign="the_gallery"}
{if !empty($the_gallery)}
{Gallery dir=$the_gallery}
{/if}

Re: Content block with Gallery picker

Posted: Fri Aug 16, 2013 10:26 pm
by compufairy
Anyone willing to send me some screenshots (or screencast) of what you're achieving with this feature? I'd love to use it for the purpose of CMS Made Simpleā„¢ Marketing. This tip may be mentioned in our next newsletter or be tweeted about by @cmsms.

Would you be so kind to send it to: anne@cmsmadesimple.org

Thanks in advance!

Anne