Updating the 'Alias Slug' for Joomla with PHP

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 9
Joined: Wed Dec 26, 2012 4:21 am

Sun Feb 03, 2013 1:16 am

Hello all.

I am trying to change the 'Alias Slug' that a Joomla article uses to make each article unique. This needs to be achieved within a PHP routine, and thus far I have achieved the following:

$slugreplace = "12345";
$query = "UPDATE yoo_zoo_item SET alias=$slugreplace WHERE id=$id";

This replaces the slug with "12345". However I would like to combine an integer with a string, as below

$id = $row['id']; //this is the unique article item number
$name = $row['name'];//this is the article title
$slugreplace = $id.$name;
$query = "UPDATE yoo_zoo_item SET alias=$slugreplace WHERE id=$id";

The original slug is not replaced. In fact, only when the variable $slugreplace contains an integer, is the slug replaced. Any value that contains a string is ignored. However I can replace the alias within Joomla itself to be any string/integer combination.

What am I missing??

I have posted this on the Joomla forum, but no answer as yet. Maybe I am missing something with PHP here ?

Thanks, Alec

Post Reply