Redirect to ext. URL not open in new tab/window (2.2.3.1)

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.
Locked
Hupi
Forum Members
Forum Members
Posts: 16
Joined: Fri Dec 25, 2015 4:03 pm

Redirect to ext. URL not open in new tab/window (2.2.3.1)

Post by Hupi »

Hi all,

I just have the following problem in CMS Version 2.2.3.1

- I create a new content page with type "Redirect (Weiterleitung)"
- Add a external url (example "https://forum.cmsmadesimple.org")
- Set target to "_blank"

The page opens always in the same tab/window as if "_self" would be selected as target. It does NOT open a new tab/window as it should.

I emptied the browser cache and also the site cache in CMSMS. Nothing helps so far.

I know with earlier 2.x.x versions this was working.

Could please someone tell me whether its a bug or what I may do wrong ?

Thanks
Hupi

PS: didn't find similar issue posted by using the search function. Sorry if I have overlooked something.
Hupi
Forum Members
Forum Members
Posts: 16
Joined: Fri Dec 25, 2015 4:03 pm

Re: Redirect to ext. URL not open in new tab/window (2.2.3.1

Post by Hupi »

I looked in the case for some more. Here some more detail on the case.

I am using the following script for the navigator:

Code: Select all

{* Main Menu *}
{if !isset($depth)}{$depth=0}{/if}
{strip}

{if $depth == 0}
		<ul class="nav navbar-nav pull-right">
	{else}
		<ul class="subMenu">
{/if}

{$depth=$depth+1}

{foreach $nodes as $node}

	{* setup classes for the anchor and list item *}
	{$liclass=[]}
	{$aclass=[]}

	{* the first child gets a special class *}
	{* if $node@first && $node@total > 1}{$liclass[]='first_child'}{/if *}

	{* the last child gets a special class *}
	{* if $node@last && $node@total > 1}{$liclass[]='last_child'}{/if *}

	{if $depth == 1}
		{* this is a page on level 1 *}
		{$liclass[]='primary'}
		{$aclass[]='firstLevel'}
	{/if}
	
	{if $node->has_children}
		{* this is a parent page *}
		{$liclass[]='dropdownSubmenu'}
		{$aclass[]='hasSubMenu'}
	{/if}
	
	{if $node->current}
		{* this is the current page *}
		{$liclass[]='active'}
		{$aclass[]='active'}
	{/if}
	
	{if $node->parent}
		{* this is a parent of the current page *}
		{$liclass[]='active'}
		{$aclass[]='active'}
	{/if}

	{* build the menu item from the node *}
	{if $node->type == 'sectionheader'}
		<li class='{implode(' ',$liclass)}'><a{if count($aclass) > 0} class="{implode(' ',$aclass)}"{/if}><span>{$node->menutext}</span></a>
		{if isset($node->children)}
			{include file=$smarty.template nodes=$node->children}
		{/if}
		</li>
	{else if $node->type == 'separator'}
		<li class="sep"></li>
	{else}
    {* regular item *}
		<li class="{implode(' ',$liclass)}"><a{if count($aclass) > 0} class="{implode(' ',$aclass)}"{/if} href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}><span>{$node->menutext}</span></a>
		{if isset($node->children)}
			{include file=$smarty.template nodes=$node->children}
		{/if}
		</li>
	{/if}
{/foreach}
{$depth=$depth-1}
</ul>
{/strip}

So a redirecting page should be using ...

Code: Select all

    {* regular item *}
		<li class="{implode(' ',$liclass)}"><a{if count($aclass) > 0} class="{implode(' ',$aclass)}"{/if} href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}><span>{$node->menutext}</span></a>
but this code returns me in the web page source code then ...

Code: Select all

<li class=""><a href="https://goo.gl/xxxx"><span>Bewerten Sie uns</span></a></li>
The "target attribute" is not showing up in the generated code, even it is set in the content page to "_blank".


--> Where is the mistake I make in my script ? (I have no idea)
--> Or is it a bug and the

Code: Select all

{if $node->target ne ""} target="{$node->target}"{/if}>
is not working ? (how can I check that)

Thanks
Hupi
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Location: Maidenhead, UK
Contact:

Re: Redirect to ext. URL not open in new tab/window (2.2.3.1

Post by paulbaker »

I have tested this on a 2.2.3.1 system and it worked as expected, adding the target attribute to an external link in a menu.

The relevant bit of my menu template is:

Code: Select all

{else}
<li><a href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}><span>{$node->menutext}</span></a>

{/if}
Are you absolutely sure you are looking at/editing the correct menu template? Be sure by adding a temporary marker ("xxx") somewhere in the template, saving, and making sure that comes up on your live site.
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... nformation

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016
Hupi
Forum Members
Forum Members
Posts: 16
Joined: Fri Dec 25, 2015 4:03 pm

Re: Redirect to ext. URL not open in new tab/window (2.2.3.1

Post by Hupi »

Hi Paul,
thanks for looking at it.

I tried now the following things:

- as suggested I added xxxx in the template to make sure it is the correct one --> the xxxx is showing up. --> confirmed. it is definitively the right one.

- checked in the database. the attribute "_blank" is in the property table and refering to the correct item id in the content table --> DB ok. property there. no problem visible (for me).

- Again went to the system maintenance and performed all possible tasks --> not a single error there eighter.

- then changed the template from ...

Code: Select all

{if $node->target ne ""} target="{$node->target}"{/if}
... to ...

Code: Select all

{if $node->target ne " "} target="{$node->target}"{/if}
... just to see what happens. --> now all items then show in the page source code ...

Code: Select all

... target=""
--> that confirms me, the IF query does add the required text. So I think the template is not the problem.

It looks to me really as if the IF clause is not doing the query in the DB.

Since I do have the exact same issue on 2 different installations (2 different provider & server) the only thing I could think of is an issue with a backend file on the servers.
Maybe a file corrupted during the last update to 2.2.3.1 or a file got corrupted when expanding the package "cmsms-2.2.3.1-install.expanded.zip" ?

I have no more ideas than that.

BR Hupi
Hupi
Forum Members
Forum Members
Posts: 16
Joined: Fri Dec 25, 2015 4:03 pm

Re: Redirect to ext. URL not open in new tab/window (2.2.3.1

Post by Hupi »

Just did some more tests:

Refreshed the installation --> no change. does not fix the problem.

Changing from php 7 to 5.6 --> no change. does not fix the problem.


Now I am totally out of ideas.

:-(

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

Re: Redirect to ext. URL not open in new tab/window (2.2.3.1

Post by velden »

So, how are you calling this Menu/Navigator? (from within the page template)
(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
Hupi
Forum Members
Forum Members
Posts: 16
Joined: Fri Dec 25, 2015 4:03 pm

Re: Redirect to ext. URL not open in new tab/window [solved]

Post by Hupi »

Oh man .... how stupid can one be :-[ :-[ :-[

That was the mistake.

I saw that in the help / documentation and checked the template header and thaught "this cant be the error, because I use these optional parameters within the pages for adding the correct footer" all the time, which works fine.

Did not think to check the line where the navigator is really called from :-[ :-[ :-[

Many thanks @Velden and and @paulbaker for your help. ANd sorry I wasted your time. Well ... wasted about 6 hours of my time too ... ::) ::) ::)

CLOSED & SOLVED
Locked

Return to “CMSMS Core”