更新' Alias Slug'用于PHP的Joomla

时间:2013-02-03 09:21:48

标签: joomla

我正在尝试更改Joomla文章用来使每篇文章与众不同的'Alias Slug'。这需要在PHP例程中实现,到目前为止我已经实现了以下目标:

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

用“12345”代替slug。但是我想将整数与字符串组合在一起,如下所示

$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";

原始的slu is没有被替换。实际上,只有当变量$ slugreplace包含一个整数时,才会替换slug。包含字符串的任何值都将被忽略。但是我可以将Joomla本身的别名替换为任何字符串/整数组合。

我错过了什么?

我已在Joomla论坛上发布此内容,但尚无答案。也许我在这里错过了PHP的东西?

谢谢,Alec

1 个答案:

答案 0 :(得分:0)

使用字符串时,您错过了引号:

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

此致