Content block with Gallery picker

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
User avatar
manuel
Power Poster
Power Poster
Posts: 353
Joined: Fri Nov 30, 2007 9:15 am

Re: Content block with Gallery picker

Post 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
Do you like your open source cms? Buy from the CMSMS partners || Donate
Jos
Support Guru
Support Guru
Posts: 4017
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: Content block with Gallery picker

Post 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();
Wishbone
Power Poster
Power Poster
Posts: 1369
Joined: Tue Dec 23, 2008 8:39 pm

Re: Content block with Gallery picker

Post 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.
tbaalham
New Member
New Member
Posts: 9
Joined: Tue Dec 06, 2011 10:26 pm

Re: Content block with Gallery picker

Post 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);
willcom
New Member
New Member
Posts: 4
Joined: Fri Jun 15, 2012 3:01 pm

Re: Content block with Gallery picker

Post 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!
chris..
Forum Members
Forum Members
Posts: 62
Joined: Thu Jun 01, 2006 8:03 pm

Re: Content block with Gallery picker

Post 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)..
User avatar
manuel
Power Poster
Power Poster
Posts: 353
Joined: Fri Nov 30, 2007 9:15 am

Re: Content block with Gallery picker

Post 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
Do you like your open source cms? Buy from the CMSMS partners || Donate
Wishbone
Power Poster
Power Poster
Posts: 1369
Joined: Tue Dec 23, 2008 8:39 pm

Re: Content block with Gallery picker

Post 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.
User avatar
manuel
Power Poster
Power Poster
Posts: 353
Joined: Fri Nov 30, 2007 9:15 am

Re: Content block with Gallery picker

Post by manuel »

Dear Wishbone,

thx for the update :)

Greetings,
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
Cerulean
Forum Members
Forum Members
Posts: 172
Joined: Mon Nov 01, 2010 8:56 am
Location: New Zealand

Re: Content block with Gallery picker

Post 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}
compufairy
Forum Members
Forum Members
Posts: 183
Joined: Sun Sep 07, 2008 10:47 am

Re: Content block with Gallery picker

Post 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
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur..." (Red Adair)
Post Reply

Return to “Tips and Tricks”