• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: cms_selflink for nonexistent alias points to root url
PostPosted: Mon Mar 25, 2019 2:08 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Sat Jul 05, 2008 8:25 pm
Posts: 88
Location: Norfolk, UK
When used with an alias that no longer exists, {cms_selflink} points to the root URL instead of my 404 page, as I'd expect.

Is this a problem with my setup, or does it always work like this? And if the latter, is there a workaround?


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: cms_selflink for nonexistent alias points to root url
PostPosted: Wed Mar 27, 2019 10:49 pm 
Offline
Dev Team Member
Dev Team Member

Joined: Mon Nov 28, 2011 9:29 am
Posts: 3121
Location: The Netherlands
The plugin will not output an url for a non-existing page alias. This results in <a href="">...</a> which leads to the homepage (usually). You can check this by looking at the page source.

This is indeed default behavior of the plugin as it is now. The CMSMS dev team recognizes it may be better to output something different and we may implement it in a future version of CMS Made Simple (but not in a minor update).

Assuming you're using the functionality of Microtiny/TinyMCE to add internal links with the wysiwyg editor:

There is not an easy workaround, though, if you know how to read and write a few lines of php code and are using CMSMS 2.x, you can override the default behavior of the plugin.
Move the cms_selflink plugin file to the /assets/plugins folder and make your changes there.

A few important notes:
- we will not support such changes and don't allow 'hacks' to be posted in this forum
- don't forget about this overriding; future upgrades will NOT touch 'your' plugin, so changes in the core plugin will not be working in your site, which will lead to unexpected behavior and/or a broken frontend/backend.
- future upgrades may re-install the plugin on the original location which can lead to a conflict (again risk of breaking frontend/backend)
- clear cache after making changes to your plugin

If you're using the plugin in templates it would be easy to check for the output first and if it's empty generate an url yourself.

\$1:
{cms_selflink href='non-existing-alias' assign=foo}
<a href="{$foo|default:"{root_url}/pagenotfound"}">link text</a>


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: cms_selflink for nonexistent alias points to root url
PostPosted: Thu Mar 28, 2019 3:39 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Sat Jul 05, 2008 8:25 pm
Posts: 88
Location: Norfolk, UK
@velden, many thanks for such a helpful reply. My PHP and Smarty skills aren't up to the fix you hinted at, though I did have a go.

And the workaround on the page itself isn't really useful unless I rewrite the existing plugin for TinyMCE, since I have users who rely on the toolbar button.

This isn't a big issue, but I am pleased to hear that at some point you might consider changing it to point to the "not found" page. To me that's the expected behaviour.

I'd also welcome a way to reference pages that would allow their aliases as well as their paths to be changed without breaking links. It's nice to be able to move a page without having to worry about updating the path, but in practice I quite often want to change the alias as well, for the sake of pretty URLs. I expect that would be a lot more complex to implement.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
A2 Hosting