Variable not expanding in AdvancedContent

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
landarone
Forum Members
Forum Members
Posts: 23
Joined: Tue Jun 24, 2014 9:24 pm

Re: Variable not expanding in AdvancedContent

Post by landarone »

Hello.
Does anyone solve this?
I mean to have some variable in Dropdown (useing AdvancedContent), in fileds Items and Values?
When I use this:

Code: Select all

{content block="select_bx1" label="Select one of" block_type="dropdown" items="One|Two|Three"}
So I see in backend SelectBox (Dropdown) with options "One" or "Two" or "Three".

When I use this:

Code: Select all

{assign var="myvalues" value="One|Two|Three"}
{content block="select_bx1" label="Select one of" block_type="dropdown" items=$myvalues}
So I see in backend SelectBox (Dropdown) with no options but with just one option, which is "$_smarty_tpl->tpl_vars['myvalues']->value"

Why is not there "One|Two|Three"?
Is it possible to give to Dropdown Items and Values some variable like "$myvalues"??

Thank you for advice/help.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1968
Joined: Mon Jan 29, 2007 4:47 pm

Re: Variable not expanding in AdvancedContent

Post by Jo Morg »

Although it seems to me it that your code should work, try this instead:

Code: Select all

{content block="select_bx1" label="Select one of" block_type="dropdown" items="{$myvalues}"}
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
landarone
Forum Members
Forum Members
Posts: 23
Joined: Tue Jun 24, 2014 9:24 pm

Re: Variable not expanding in AdvancedContent

Post by landarone »

Hello Jo Morg.
I tried what you wrote but it didn't work too. If I do it so in dropdown I see this (as only one option):

((string)$_smarty_tpl->tpl_vars['myvalues']->value)

For me it looks like the code is not completely wrong, but something missing there, some delimiter or parameter. Maybe something like "myvalues.value" or "myvalues->value"......?
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1968
Joined: Mon Jan 29, 2007 4:47 pm

Re: Variable not expanding in AdvancedContent

Post by Jo Morg »

landarone wrote:For me it looks like the code is not completely wrong, but something missing there, some delimiter or parameter. Maybe something like "myvalues.value" or "myvalues->value"......?
Nope...

Code: Select all

{assign var="myvalues" value="One|Two|Three"}
{$myvalues} {* this should print: One|Two|Three  *}
It does seem like a bug in AdvancedContent.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
chandra

Re: Variable not expanding in AdvancedContent

Post by chandra »

Can't see the delimiter param inside your call (yeah, AdvancedContent has such one ;))
landarone
Forum Members
Forum Members
Posts: 23
Joined: Tue Jun 24, 2014 9:24 pm

Re: Variable not expanding in AdvancedContent

Post by landarone »

Hello Jo Morg. This code

Code: Select all

{assign var="myvalues" value="One|Two|Three"}
{$myvalues} {* this should print: One|Two|Three  *}
as you wrote is working on 100%.

I see in page line with "One|Two|Three".
But if I use this variable "$myvalues" for Dropdown it doesnt work :(

Bug in AdvancedContent? I rather be thinking that bug is between my keyboard and my chair :)

Ufff, I will try to do some other test how to fill Items filed with variable. Hope to not lose my mind.....


Hello chandra.
It is no difference if I use Delimiter parameter (delimiter="|").

Code: Select all

{assign var="myvalues" value="One|Two|Three"}
{content block="select_bx1000" label="Select one of 3" block_type="dropdown" items=$myvaluesss delimiter="|"}
I still see "$_smarty_tpl->tpl_vars['myvalues']->value" as option in dropdown :(
chandra

Re: Variable not expanding in AdvancedContent

Post by chandra »

Do you are using the latest module version?
landarone
Forum Members
Forum Members
Posts: 23
Joined: Tue Jun 24, 2014 9:24 pm

Re: Variable not expanding in AdvancedContent

Post by landarone »

I guess I have the latest version of AdvancedContent, I have "0.9.4.3" and CMS is "1.11.7 Genovesa".

Just a while ago I tried to use UDT with

Code: Select all

echo "One|Two|Three";
and call it like

Code: Select all

.....items=":::myudt_testa:::" smarty="true"}
and this also works, I see 3 options in backend now.

So I tried to use and call udt little bit diffrent:

Code: Select all

echo $params['name'];
and in template:

Code: Select all

.....items=":::myudt_testa name=$myvalues:::" smarty="true"}
and you know what? Nothing.......instead of 3 options is there only one with value ".((string)->tpl_vars['myvaluesss']->value)."

Why me, why me.... :(
staartmees
Power Poster
Power Poster
Posts: 1049
Joined: Wed Mar 19, 2008 4:54 pm

Re: Variable not expanding in AdvancedContent

Post by staartmees »

your CMSMS is outdated, current version is 1.11.10
landarone
Forum Members
Forum Members
Posts: 23
Joined: Tue Jun 24, 2014 9:24 pm

Re: Variable not expanding in AdvancedContent

Post by landarone »

Ok, so I updated CMS to version "1.11.10" and all modules too.
Now I have everything in latest version.
But no difference, I still can't see $myvaluesss in options for block_type="dropdown".

I even try this (UDT name Param_test):

Code: Select all

$row = $smarty->get_template_vars('myvaluesss');
echo $row;
Result is that if I call {Param_test} so I see line of text: One|Two|Three
If I call {content block='drp_boxpok1' label='Select TZN' block_type="dropdown" items=":::Param_test:::" smarty=true} then in options is nothing, no value, no part of code.....nothing

Reason why I'm trying to do that is I would like to have ordinary Content page where I define simple content block, where user can fill just line of text like: "One,Two,Three".
In a child page I need to get this value (with function get_parent_alias, ......) and assign it to Items in block_type="dropdown". So user can easily select one of values which he defined in parent page.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1968
Joined: Mon Jan 29, 2007 4:47 pm

Re: Variable not expanding in AdvancedContent

Post by Jo Morg »

Ok... not sure if it is a bug or a limitation, as the way the template is parsed from the backend is different than that of the frontend. It seems that what is failing here is getting $myvalues evaluated by smarty.
You may have to move all the logic to the UDT and have it echo the results without any other smarty evaluation. BTW you can use cgsimple::get_parent_alias() inside the UDT if you need to (without the enclosing {...} ).
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
chandra

Re: Variable not expanding in AdvancedContent

Post by chandra »

Not sure if it's the reason for your problem.

But if you give items (=key) you should also give values (param values).
landarone
Forum Members
Forum Members
Posts: 23
Joined: Tue Jun 24, 2014 9:24 pm

Re: Variable not expanding in AdvancedContent

Post by landarone »

Thank you all of you for support and advices.
I finally found solution. It seems like it is not possible to use smarty variables in backend, not for filling another value/parameter like Items for Dropdown.
I think it is because in admin (backend) is page not fully generated like when you open page on frontend. So for me it looks that Smarty for backend is different then for frontend.

I couldn't give values to Items with any code useing smarty. I tried many ways, but no one leeds to right result, every time I saw part of code, name of property or blank field for option (Items) in backend Dropdown.
So I left this way and try to do own UDT with straight PHP code and querry do DB. I'm more coder and graphic guy then programmer so it tooks me longer time, but I have it :)
In UDT I useing function GET for getting ID of page from URL, it is also in URL when you edit page in admin.
And if I have this ID so I can do querry to DB and get content of block for parent page, where is field with "One,Two,Three".
And this I sent to Items with clasic echo line and for Dropdown I use delimiter="," and it works in the way I need, finally :)

So again, thank you all for advices and help.
Now I have to solve another issue, why URL in search not returning pretty url for news - just only for news (http://forum.cmsmadesimple.org/viewtopi ... 28&t=69577)
Post Reply

Return to “Modules/Add-Ons”