| | | |  |  | |  |
09.06.2004, 22:28
|
#1 (permalink)
| | Professional Mamber
Join Date: Apr 2004 Location: Northern Germany
Posts: 713
| Please review my first Mambot Hi,
I just finished my FIRST mambot. It's used to add links to all other articles with the same Category to the content. I just wanted to ask if there are easier ways to solve the problem (e.g. is there a variable i can use for the category of the actual content?). For me it works fine on my website.
Here is the code (feel free to use it or criticise it!): Code: <?php
/**
* moscategory mambot
* @by Thomas Kahl
* @package Mambo Open Source
* @Copyright (C) 2004
* @ All rights reserved
* @ Mambo Open Source is Free Software
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
* @used parts of mod_related_items
**/
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
if (strtolower($option)=="content" and $id<>"" and strtolower(mosGetParam( $_REQUEST, 'task', "" ))=="view") {
// select other items based on the metakey field 'like' the keys found
$query = "SELECT #__content.catid, #__categories.name FROM #__content, #__categories WHERE #__content.catid=#__categories.id and #__content.id=$id";
$database->setQuery( $query );
$catrows = $database->loadObjectList();
$catrow = $catrows[0];
$vglcat=$catrow->catid;
$vglcatname=$catrow->name;
if ($vglcat<>"") {
// now gather all other content with this CATID
$query = "SELECT #__content.id, #__content.title"
. "\nFROM #__content"
. "\nWHERE #__content.catid=$vglcat and #__content.id<>$id AND state=1 AND #__content.access <=$my->gid";
$query .= " order by #__content.ordering";
$linkblock="";
$database->setQuery( $query );
if ($related = $database->loadObjectList()) {
$linkblock.= 'Related Items - "'.$vglcatname.'"';
$linkblock.= '<table cellspacing="0" cellpadding="1" align="left" class="moduletable" style="width: 100%">';
foreach ($related as $item) {
$linkblock.= '<tr><td>';
$linkblock.= '<img src="'.$mosConfig_live_site.'/images/M_images/indent1.png" border="0" alt="" />';
$linkblock.= "<a href=\"index.php?option=content&task=view&id=$item->id\">$item->title</a></td></tr>";
}
$linkblock.= '</table>';
}
echo $database->getErrorMsg();
if ($linkblock<>"") {
$row->text.=$linkblock;
}
}
}
?> Bye, Zork
Edit: just corrected two errors...
P.S.: You can see an example here
Last edited by zorkhh; 09.06.2004 at 23:30.
|
| |
10.06.2004, 10:25
|
#2 (permalink)
| | Senior Mamber
Join Date: Apr 2004 Location: Hamburg/Germany
Posts: 241
| Re: Please review my first Mambot I've saved your code to a file named moscategory.php and put it in /mambots. Actually what effect should it make? Didn't realize any changes to my content though.
regards,
novocaine |
| |
10.06.2004, 10:37
|
#3 (permalink)
| | Professional Mamber
Join Date: Apr 2004 Location: Northern Germany
Posts: 713
| Re: Please review my first Mambot Hi Novocaine!
As you can see in my example, there is a list of links under the content where all the articles of the same category are shown.
This only works on "Content-Section-Category-Items".
In all of my (5) sites it works fine.
Zork |
| |
10.06.2004, 22:09
|
#4 (permalink)
| | Professional Mamber
Join Date: Apr 2004 Location: Gap / France
Posts: 860
| Re: Please review my first Mambot Hi, can be you more specific?
Tried the same as novo', and saw no change..?
The code doesn't look like it needs to be called by {moscategory},
is there anything else appart from placing the file into the mambots dir' that needs to be done?
Danke. |
| |
10.06.2004, 22:32
|
#5 (permalink)
| | Professional Mamber
Join Date: Apr 2004 Location: Marikina, Manila, Philippines
Posts: 776
| Re: Please review my first Mambot I get Quote: |
Notice: Undefined variable: id in C:\apache2\htdocs\Mambo\stingrey\mambots\moscatego ry.php on line 15
|
And yes I have set error reporting to Maximum, helps me debug my modules as I develop them
__________________ Joomla! Core Team Member
Software Coding & Design - Stability Team Leader www.joomla.org Former Mambo Core Team Member |
| |
10.06.2004, 23:34
|
#6 (permalink)
| | Professional Mamber
Join Date: Apr 2004 Location: Northern Germany
Posts: 713
| Re: Please review my first Mambot Hi,
first of all - thank you for trying!
This mambot just adds links to all the items in the same category as the shown article:
I think i know what the problem is. Do you all use "searchenginefriendly URLs"? Then maybe this if-clause Code: strtolower(mosGetParam( $_REQUEST, 'task', "" ))=="view" may be the problem. You don't have the "task-parameter" in your URL. But do you know, how i can figure out that the selected content is a complete article an not just a blog?
Zork |
| |
11.06.2004, 00:14
|
#7 (permalink)
| | Professional Mamber
Join Date: Apr 2004 Location: Gap / France
Posts: 860
| Re: Please review my first Mambot Of course, no task, no bot 
Good, fast debugging.
Now, do I turn SEF off or not ...  |
| |
13.06.2004, 12:58
|
#8 (permalink)
| | Professional Mamber
Join Date: Apr 2004 Location: Marikina, Manila, Philippines
Posts: 776
| Re: Please review my first Mambot Hi Thomas,
hope you dont mind but I've played with your mosbot and heavily modified it.
I will make it available soon on MOSforge and give you a link to it to use on your mosbots site.
Basically I cleaned up the code, added mamblefish support, SEF support and added some settings that users can configure without having to play with the code too much. I'm trying to see if I can ceate a simple Admin Backend for to make these settings more easily configurable - I suspect i wont be able to do this, but I'll at least try.
You can see it working on my site: www.stingrey.biz
__________________ Joomla! Core Team Member
Software Coding & Design - Stability Team Leader www.joomla.org Former Mambo Core Team Member |
| |
13.06.2004, 14:54
|
#9 (permalink)
| | Professional Mamber
Join Date: Apr 2004 Location: Gap / France
Posts: 860
| Re: Please review my first Mambot stingrey, this looks really good on your site!
any idea when it'll be out..? (don't wanna disable SEF really) |
| |
13.06.2004, 14:59
|
#10 (permalink)
| | Professional Mamber
Join Date: Apr 2004 Location: Northern Germany
Posts: 713
| Re: Please review my first Mambot Thank you for your work!
Now my version work with SEF too, but i'd prefer to see yours. So i'll wait, until you give me the link to the bot.
(But the idea for this bot was good - wasn't it?  )
Zork |
| | | Thread Tools | Search this Thread | | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT +2. The time now is 10:33. | | | |