Page 1 of 1

v2.2.3.1 trouble with core tag functionality with assign

Posted: Thu Feb 01, 2018 10:41 am
by rbaby
Hi guys,

I can't seem to figure out what I am doing wrong with assign and calling it.
I'm using cms_selflink tag in my template:

{cms_selflink dir='prev' href='page_alias' assign='prev'} declared at the top and then:

Code: Select all

<div class="controls controls-prev"><a href="{$prev}"><i class="fa fa-chevron-left"></i></a></div>
The HTML output is nothing.

--

I'm also using the assign functionality on an image:

Code: Select all

{content_image block='stage_image' label='Stage Image' urlonly='1' exclude='thumb_' dir='images/stage' assign='stageimage'}
and {$stageimage} outputs nothing

--

Am I doing something wrong? I do have a {content} in the template and that seems fine but it seems that whenever I assign anything to it, it doesn't seem to render. Any insight would be greatly appreciated. Is there a cache I need to clear or something...? I see no errors but it just doesn't seem to do anything :(...



CMSMS v2.2.3.1

Re: v2.2.3.1 trouble with core tag functionality with assign

Posted: Thu Feb 01, 2018 10:58 am
by velden
Where in the template do you do the assign and where do you try to read the variabele?

https://www.cmscanbesimple.org/blog/sma ... e-examples

(Note that the order is Top, Body, Head)

Re: v2.2.3.1 trouble with core tag functionality with assign

Posted: Thu Feb 01, 2018 2:16 pm
by Rolf

Re: v2.2.3.1 trouble with core tag functionality with assign

Posted: Thu Feb 01, 2018 6:59 pm
by PinkElephant
Hi rbaby
rbaby wrote:{cms_selflink dir='prev' href='page_alias' assign='prev'}
No output here either. I'm not sure if it's docs or code but {cms_selflink dir='prev' urlonly=1 assign='prev'} seems to work.
rbaby wrote:

Code: Select all

{content_image block='stage_image' label='Stage Image' urlonly='1' exclude='thumb_' dir='images/stage' assign='stageimage'}
As mentioned, looks like scope.

Re: v2.2.3.1 trouble with core tag functionality with assign

Posted: Thu Feb 01, 2018 7:52 pm
by rbaby
Thank you guys, will try it!

Re: v2.2.3.1 trouble with core tag functionality with assign

Posted: Fri Feb 02, 2018 4:11 am
by rbaby
PinkElephant wrote:Hi rbaby
rbaby wrote:{cms_selflink dir='prev' href='page_alias' assign='prev'}
No output here either. I'm not sure if it's docs or code but {cms_selflink dir='prev' urlonly=1 assign='prev'} seems to work.
rbaby wrote:

Code: Select all

{content_image block='stage_image' label='Stage Image' urlonly='1' exclude='thumb_' dir='images/stage' assign='stageimage'}
As mentioned, looks like scope.
For some reason, that worked. Thank you. Any way I can only have it go prev/next within siblings and if it's the last, "next" to go to the parent?

Re: v2.2.3.1 trouble with core tag functionality with assign

Posted: Fri Feb 02, 2018 5:47 am
by velden
'page_alias' is supposed to be an existing page alias.

IIRC $page_alias variable contains the page alias of current page. So {cms_selflink href=$page_alias ...} should work too. Note that you should NOT enclose the $page_alias variable with quotes!

Re: v2.2.3.1 trouble with core tag functionality with assign

Posted: Fri Feb 02, 2018 12:27 pm
by PinkElephant
rbaby wrote:Any way I can only have it go prev/next within siblings and if it's the last, "next" to go to the parent?
I'm not exactly sure what you mean by that but the cms_selflink tag can cover basic navigation...

Code: Select all

<h2>DEBUG</h2>

{cms_selflink dir='prev' urlonly=1 assign='x_prev'}
{cms_selflink dir='next' urlonly=1 assign='x_next'}
{cms_selflink dir='start' urlonly=1 assign='x_start'}
{cms_selflink dir='up' urlonly=1 assign='x_up'}

<p>prev={$x_prev}</p>
<p>next={$x_next}</p>
<p>start={$x_start}</p>
<p>up={$x_up}</p>

<hr>

{if empty($x_next)}
	<p>Nowhere left to go. Might as well go back
		{if {$x_up} != {$x_start}}
			up: {$x_up}
		{else}
			home: {$x_start}
		{/if}
	</p>
{/if}

<hr>
... but if you want something funkier then you might be better off calling {Navigator} with a template to iterate through the node hierarchy and do stuff as appropriate.

Re: v2.2.3.1 trouble with core tag functionality with assign

Posted: Sat Feb 03, 2018 11:57 am
by PinkElephant
lib/plugins/function.cms_selflink.php (2.2.5) shows a couple of undocumented dir options which might be handy;

prevpeer (or 'prevsibling')
nextpeer (or 'nextsibling')

... when these go empty you're at the start/end of level.