"Alias" field in _content updating

7 years 3 months ago #102 by dbode
"Alias" field in _content updating was created by dbode

we have this code in content.php (don't know if I did it myself or if it's in the code by default, we discussed it some weeks ago):
//if no alias given, convert it from title
if(!$app->request->params('alias') && $app->request->params('title')){
                        $article->alias = JFilterOutput::stringURLSafe($app->request->params('title'));
                    }// if alias given, change it! 
                    if($app->request->params('alias') ){
                        $article->alias = JFilterOutput::stringURLSafe($app->request->params('alias'));

So, the alias field will be updated, when given. If not, take it from title.
However, I changed this line for myself, due to SEO issues! Here's why:

When I create an article for the first time and set it to published afterwards, everything's ok.
The article goes live and everyone's happy.
Now I have to add content for an update of that article, so I change the title as well and append something like "[update]". Unfortunately, the alias will be changed as well! But this is also changes the URL at all and you may lose your old one, which results in 404 errors (e.g. because of "old" sitemaps).

So, here's my edited code which emulates the Joomla backends behaviour much closer:
            if(!$app->request->params('alias') && $app->request->params('title') && $app->request->params('state') !== '1'){
                        $article->alias = JFilterOutput::stringURLSafe($app->request->params('title'));

Now, the alias (so the URL at all) is changing only, when the article is not live (state not equal 1). IF it's live, the alias will only change, if it's given from the calling source.

What do you think about it?

Please Log in or Create an account to join the conversation.

7 years 3 months ago #103 by steve.tsiopanos
Replied by steve.tsiopanos on topic "Alias" field in _content updating
This is an excellent observation and I will make sure to include this as an update with cAPI 1.2.8 (currently working on Tags as the major new feature).

Please Log in or Create an account to join the conversation.

Cron Job Starts