Page 1 of 2

How to call a Gallery smarty tag from a UDT?

Posted: Sun Aug 03, 2014 5:58 pm
by rogerlatur
I am trying to call this Smarty tag
{Gallery dir='Content_images' img='66'}
from a UDT, without success.

I've seen this example, but it does not work.

Re: How to call a Gallery smarty tag from a UDT?

Posted: Mon Aug 04, 2014 12:16 am
by Jo Morg
What are you trying to achieve?
Although possible, and in some situations the only solution to get an specific result, it's not recommended to use it if there are alternatives...

Re: How to call a Gallery smarty tag from a UDT?

Posted: Mon Aug 04, 2014 8:37 am
by Rolf
rogerlatur wrote:I've seen this example, but it does not work.
Yes, it does! ;)

Re: How to call a Gallery smarty tag from a UDT?

Posted: Mon Aug 04, 2014 9:08 am
by rogerlatur
Jo Morg wrote:What are you trying to achieve?
Although possible, and in some situations the only solution to get an specific result, it's not recommended to use it if there are alternatives...
This tag is cool cause it adds an image and takes all lytebox parameters too (opens in a new window on click etc etc):

Code: Select all

{Gallery dir='Content_images' img='66'} 
Now I'd like to be able to add 2 images, centered on the page (with a little distance between both, but that's a detail). To do so I'm actually adding UDTs before, between, after!

Code: Select all

{image_left_center_open}{Gallery dir='Content_images' img='47'}{image_right_center_open}{Gallery dir='Content_images' img='27'}{image_right_center_close}
Very dirty method IMO, mostly for the use who's gone use cmms!!!

As I don't know where is the php to edit directly what the smarty tag "Gallery" does (I asked here but my question was never displayed), I thought I'd ask how to manipulate a tag in a tag!

I think it's much better if I can modify the php itself, but could not find it :)

Re: How to call a Gallery smarty tag from a UDT?

Posted: Mon Aug 04, 2014 10:36 am
by Jos
Maybe it is the call itself. It makes no sense to have the parameters dir and img at the same time.

Re: How to call a Gallery smarty tag from a UDT?

Posted: Mon Aug 04, 2014 10:44 am
by Jo Morg
rogerlatur wrote:As I don't know where is the php to edit directly what the smarty tag "Gallery" does (I asked here but my question was never displayed), I thought I'd ask how to manipulate a tag in a tag!
The question implied hacking the module so it violated the forum rules...

Re: How to call a Gallery smarty tag from a UDT?

Posted: Mon Aug 04, 2014 11:41 am
by Jos
I remember somebody asked in which file parameters are defined.
Was that you?
I don't agree that just asking where a file can be found, is a violation of forum rules :-X
http://forum.cmsmadesimple.org/viewtopi ... 40&t=28132
But it wouldn't have helped you anyway.
Now I'd like to be able to add 2 images, centered on the page (with a little distance between both, but that's a detail). To do so I'm actually adding UDTs before, between, after!
The proper way would be to create a subgallery, upload the two images, assign the gallery-template of your choice. You can create/copy a gallery-template and edit the css to get the extra space (margin).
In your content page you have nothing else to do than call the subgallery with {Gallery dir='yoursubgallery'}

Re: How to call a Gallery smarty tag from a UDT?

Posted: Mon Aug 04, 2014 11:47 am
by Jo Morg
Jos wrote:I don't agree that just asking where a file can be found, is a violation of forum rules :-X
viewtopic.php?f=40&t=28132
But it wouldn't have helped you anyway.
I was just guessing by this statment:
rogerlatur wrote:As I don't know where is the php to edit directly what the smarty tag "Gallery" does (I asked here but my question was never displayed)
It wasn't me who moderated the post anyway so I don't really know about what was written on the deleted post other then by this statement. :)

Re: How to call a Gallery smarty tag from a UDT?

Posted: Mon Aug 04, 2014 7:58 pm
by rogerlatur
It would be the first time for me that modifying an open source php file is considered as a hacking fact!
As long as you don't use it commercially, keep all copyrights, headers etc, I really don't see what would be wrong in doing this.
Imagine if nobody was able to modify anything, then the open source world would be dead since a long time.

Re: How to call a Gallery smarty tag from a UDT?

Posted: Mon Aug 04, 2014 8:02 pm
by rogerlatur
Jo Morg wrote:
rogerlatur wrote:As I don't know where is the php to edit directly what the smarty tag "Gallery" does (I asked here but my question was never displayed), I thought I'd ask how to manipulate a tag in a tag!
The question implied hacking the module so it violated the forum rules...
Now I see that I got the reason why my post was deleted.
I thought you were jocking. It seems that you are not. Only pathetic.

Re: How to call a Gallery smarty tag from a UDT?

Posted: Mon Aug 04, 2014 8:06 pm
by rogerlatur
I found the file.

Just that you know.:

Code: Select all

# This program is free software; [b]you can redistribute it and/or modify
# it under the terms of the GNU General Public License[/b] as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

Re: How to call a Gallery smarty tag from a UDT?

Posted: Mon Aug 04, 2014 9:08 pm
by rogerlatur
Rolf wrote:
rogerlatur wrote:I've seen this example, but it does not work.
Yes, it does! ;)
I tried with this:

Code: Select all

$smarty = cmsms()->GetSmarty();
$smarty_data = "{Gallery}";
echo $smarty->display($smarty_data);
and I get only errors.

Code: Select all

httpdocs/lib/smarty/Smarty.class.php:1593 - trigger_error
/httpdocs/lib/smarty/Smarty.class.php:1415 - _fetch_resource_info
/httpdocs/lib/smarty/Smarty.class.php:1254 - _compile_resource
/httpdocs/lib/smarty/Smarty.class.php:1106 - fetch
/httpdocs/lib/classes/class.usertagoperations.inc.php(260) : eval()'d code:8 - display
etc etc

Re: How to call a Gallery smarty tag from a UDT?

Posted: Mon Aug 04, 2014 9:35 pm
by Jo Morg
rogerlatur wrote:Now I see that I got the reason why my post was deleted.
I thought you were jocking. It seems that you are not. Only pathetic.
I do hope I'm misinterpreting this...

rogerlatur wrote:I found the file.

Just that you know.:

Code: Select all

# This program is free software; [b]you can redistribute it and/or modify
# it under the terms of the GNU General Public License[/b] as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
You can modify it all you want, but the rules are there for a reason: if you know what you are doing fine; if you don't, and the module stops working you most likely won't get support here. Others may apply the hack blindly and it may create more troubles that the ones it was eventually trying to solve;

In conclusion: you can modify the module files; you can't post those modifications on the forum as they will be considered a hack and a violation of the forum rules;


I hope you do understand and, in the future, avoid labeling any of the members of this community...

Re: How to call a Gallery smarty tag from a UDT?

Posted: Mon Aug 04, 2014 10:01 pm
by Jos
Rolf's UDT works fine like this

Code: Select all

$img = isset($params['img']) ? $params['img'] : '';
$smarty_data = "{Gallery img='".$img."'}";
$smarty->display('eval:'.$smarty_data);
But I'd rather like to refer to the solution provided in my former post

Re: How to call a Gallery smarty tag from a UDT?

Posted: Tue Aug 05, 2014 5:28 pm
by rogerlatur
Jos wrote:Rolf's UDT works fine like this

Code: Select all

$img = isset($params['img']) ? $params['img'] : '';
$smarty_data = "{Gallery img='".$img."'}";
$smarty->display('eval:'.$smarty_data);
No matter how I call it, with 'echo' or not, I always have the errors listed above.
Maybe because I run version 1.10.3.
I tried yesterday to upgrade CMSMS and it turned to a real nightmare !
All UDTs broken etc etc.
First time ever I have an issue ugrading/updating a CMS. I guess I am getting old.
Jos wrote:But I'd rather like to refer to the solution provided in my former post
I agree. Thank you very much for the help.