Target _blank always comes empty?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
scottx
New Member
New Member
Posts: 4
Joined: Fri Apr 13, 2018 12:01 am

Target _blank always comes empty?

Post by scottx »

Hi,

I added a content page of type Redirecting Link and set the Target to _blank but it's not working.

The logic to display the target is there but the value target always comes empty. I'm printing the node's content with {$node|@print_r}.

Can anyone help me understanding this behaviour?

Thanks in advance,
Ricardo
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1609
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: Target _blank always comes empty?

Post by DIGI3 »

any chance you have loadprops=0 in your Navigator call?
Not getting the answer you need? CMSMS support options
scottx
New Member
New Member
Posts: 4
Joined: Fri Apr 13, 2018 12:01 am

Re: Target _blank always comes empty?

Post by scottx »

Thank you for your quick answer DIGI3. I don't think I'm calling that property.

I have these options enabled:
Listable: Yes
Type: Navigator::Navigation
Default: No
Category: None

And this is the code:

Code: Select all

{* simple navigation *}
{* note, function can only be defined once *}
{* 
  variables:
  node: contains the current node.
  aclass: is used to build a string containing class names given to the a tag if one is used
  liclass: is used to build a string containing class names given to the li tag.
*}

{$main_id = ' id=\'mainNav\''}

{function name=Nav_menu depth=1}{strip}
<!-- <ul class="nav nav-pills" id="mainNav"> -->
<ul {if isset($ulclass) && $ulclass !='' } class="{$ulclass}" {/if} {$main_id}>
  {$main_id = ''}
  {$ulclass = ''}
  {foreach $data as $node}
    {* setup classes for the anchor and list item *}
    {* {assign var='liclass' value='menudepth'|cat:$depth} *}
    {assign var='liclass' value=''}
    {assign var='aclass' value=''}

    {* the first child gets a special class *}
    {* {if $node@first && $node@total > 1}{assign var='liclass' value=$liclass|cat:' first_child'}{/if} *}

    {* the last child gets a special class *}
    {* {if $node@last && $node@total > 1}{assign var='liclass' value=$liclass|cat:' last_child'}{/if} *}

    {if $node->current}
      {* this is the current page *}
      {* {assign var='liclass' value=$liclass|cat:' active'} *}
      {assign var='aclass' value=$aclass|cat:' active'}
    {/if}

    {if $node->parent}
      {* this is a parent of the current page *}
      {assign var='liclass' value=$liclass|cat:' active dropdown-submenu'}
      {assign var='aclass' value=$aclass|cat:' active menuparent'}
    {/if}

    {if $node->children_exist}
      {if $node->depth > 1}
        {assign var='liclass' value='dropdown-submenu'}
      {else}
        {assign var='liclass' value='dropdown'}
      {/if}
      {assign var='ulclass' value='dropdown-menu'}
      {* {assign var='aclass' value=$aclass|cat:' dropdown-item dropdown-toggle'} *}
      {assign var='aclass' value=$aclass|cat:' dropdown-item dropdown-toggle'}
    {else}
      {assign var='aclass' value=$aclass|cat:' nav-link'}
    {/if}

    {* {$node|@print_r} *}
    {* build the menu item node *}
    {if $node->type == 'sectionheader'}
      <li class='dropdown {$liclass}'>{$node->menutext}
        {if isset($node->children)}
          {Nav_menu data=$node->children depth=$depth+1}
        {/if}
      </li>
    {else if $node->type == 'separator'}
      <li class='separator {$liclass}'><hr class='separator'/></li>
    {else}
      {* regular item *}
      

      {* THIS IS THE SECTION WHERE I WANT TO ADD THE TARGET BLANK *}
      <li class="{$liclass}">
        {$node|@print_r}
        <a class="{$aclass}" href="{$node->url}" {if $node->target != ''} target="{$node->target}"{/if}>{$node->menutext}</a>
          {if isset($node->children)}
            {Nav_menu data=$node->children depth=$depth+1 ulclass=$ulclass}
          {/if}
      </li>
      {* THIS IS THE SECTION WHERE I WANT TO ADD THE TARGET BLANK *}


    {/if}
  {/foreach}
</ul>
{/strip}{/function}

{if isset($nodes)}
{Nav_menu data=$nodes depth=0 ulclass='nav nav-pills'}
{/if}
This is what I get for the node I have with target set to blank
NavigatorNode Object ( [id] => 45 [url] => https://www.google.com/ [accesskey] => [type] => link [tabindex] => 0 [titleattribute] => [modified] => 1523577146 [created] => 1523399393 [hierarchy] => 8 [depth] => 1 [menutext] => Google [raw_menutext] => Google [target] => [alias] => google-example [current] => [parent] => [has_children] => [children_exist] => ) 1

Am I missing something?

Much appreciated.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Target _blank always comes empty?

Post by velden »

DIGI3 is hinting to the loadprops parameter of the {Navigator} tag.

From the Navigator module help:
(optional) loadprops="" - Use this parameter when NOT using advanced properties in your navigator template. This will disable the loading of all of the content properties for each node (such as extra1, image, thumbnail, etc.). This will dramatically decrease the number of queries required to build a navigation, and increase memory requirements, but will remove the possibility for much more advanced displays
With loadprops is set to false/0
{Navigator loadprops='0' template='Simplex Main Navigation'}

Code: Select all

    [id] => 35
    [url] => http://www.cmsmadesimple.org
    [accesskey] => 
    [type] => link
    [tabindex] => 0
    [titleattribute] => 
    [modified] => 1523611834
    [created] => 1523611786
    [hierarchy] => 7
    [depth] => 1
    [menutext] => Blank redirect
    [raw_menutext] => Blank redirect
    [target] => 
    [alias] => blank-redirect
    [current] => 
    [parent] => 
    [has_children] => 
    [children_exist] => 
{Navigator loadprops=true template='Simplex Main Navigation'}

Code: Select all

    [id] => 35
    [url] => http://www.cmsmadesimple.org
    [accesskey] => 
    [type] => link
    [tabindex] => 0
    [titleattribute] => 
    [modified] => 1523611834
    [created] => 1523611786
    [hierarchy] => 7
    [depth] => 1
    [menutext] => Blank redirect
    [raw_menutext] => Blank redirect
    [target] => _blank
    [alias] => blank-redirect
    [current] => 
    [parent] => 
    [has_children] => 
    [children_exist] => 
    [extra1] => extra1 value
    [extra2] => extra2 value
    [extra3] => extra3 value
    [image] => http://temp.contentwebsites.nl/cmsms2/uploads/images/logo1.gif
    [thumbnail] => http://temp.contentwebsites.nl/cmsms2/uploads/images/thumb_logo1.gif
scottx
New Member
New Member
Posts: 4
Joined: Fri Apr 13, 2018 12:01 am

Re: Target _blank always comes empty?

Post by scottx »

Fixed, I was looking into the code to build the menu, not in the header template where I call the nav ;D
Yes, I had loadprops='0' and when switched to '1' it started loading.
Sorry guys, thank you so much for your help!
Cheers! :)
Post Reply

Return to “CMSMS Core”