Fiji Web Design
Welcome, Guest
Please Login or Register.    Lost Password?
Re:How to add additional text (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:How to add additional text
#587
admin (Admin)
Admin
Posts: 475
graph
User Online Now Click here to see the profile of this user
Re:How to add additional text 3 Years, 1 Month ago Karma: 10  
Only the category ID is given. So to get the category, you'd need a mysql query:
$query = "SELECT title FROM #__categories WHERE id = ".intval($article->catid)." LIMIT 1";
$database->setQuery($query);
$category = $database->loadResult();
The variable $category should now have the category title so the text looks like.
$custom_text = 'this '.$article->title.' belongs to '.$category;
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#589
p0oo9ip0o (User)
Fresh Boarder
Posts: 11
graphgraph
User Offline Click here to see the profile of this user
Re:How to add additional text 3 Years ago Karma: 0  
Where should i post this code?
$query = "SELECT title FROM #__categories WHERE id = ".intval($article->catid)." LIMIT 1";  
$database->setQuery($query);  
$category = $database->loadResult();
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#608
p0oo9ip0o (User)
Fresh Boarder
Posts: 11
graphgraph
User Offline Click here to see the profile of this user
Re:How to add additional text 3 Years ago Karma: 0  
knock knock..
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#617
admin (Admin)
Admin
Posts: 475
graph
User Online Now Click here to see the profile of this user
Re:How to add additional text 3 Years ago Karma: 10  
Anywhere above:
$custom_text = 'this '.$article->title.' belongs to '.$category;
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#629
p0oo9ip0o (User)
Fresh Boarder
Posts: 11
graphgraph
User Offline Click here to see the profile of this user
Re:How to add additional text 3 Years ago Karma: 0  
i saw this message

Parse error: syntax error, unexpected '=' in /home/p0o9ip0o/public_html/plugins/content/botphp_content.php(53) : eval()'d code on line 6

i used this code
<?php $query = "SELECT title FROM #__categories WHERE id = ".intval($article->catid)." LIMIT 1";  
$database->setQuery($query);  
$category = $database->loadResult();  
custom_text = 'this '.$article->title.' belongs to '.$category;
$article->text = str_replace('{additionaltext}', $custom_text, $article->text); ?>
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#630
admin (Admin)
Admin
Posts: 475
graph
User Online Now Click here to see the profile of this user
Re:How to add additional text 3 Years ago Karma: 10  
This line:

custom_text = 'this '.$article->title.' belongs to '.$category;

Should be:

$custom_text = 'this '.$article->title.' belongs to '.$category;

Variables in PHP must begin with "$".
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Joomla Downloads

DownloadsDownload our free Joomla! Components, Modules and Plugins.