Using Xmap+Ads Manager Resurrected [solved]
4 posts
• Page 1 of 1
Using Xmap+Ads Manager Resurrected [solved]
Attached working plugin in my last post.
I'm trying to use Xmap with Ads Manager Resurrected. AMR is a further developmend of the ads manager from joomprod
This is my xml and php code any help would be appreciated.
com_amresurrected.xml
com_amresurrected.php
The xml file seems to work fine because I'm able to change the settings in the back-end.
Requesting the url to the sitemap still only give me my menu items and not my ads so the php file needs some tinkering.
I'm trying to use Xmap with Ads Manager Resurrected. AMR is a further developmend of the ads manager from joomprod
This is my xml and php code any help would be appreciated.
com_amresurrected.xml
- Code: Select all
<?xml version="1.0" encoding="iso-8859-1"?>
<install type="xmap_ext" version="1.5.0">
<name> Ads Manager Plugin</name>
<author>Guillermo Vargas</author>
<creationDate>2008/08/15</creationDate>
<copyright>GNU GPL</copyright>
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
<authorEmail>guille@vargas.co.cr</authorEmail>
<authorUrl>joomla.vargas.co.cr</authorUrl>
<version>1.0.1</version>
<description>Plugin for Ads Manager component</description>
<files>
<filename xmap_ext="com_amresurrected">com_amresurrected.php</filename>
</files>
<params>
<param name="include_ads" type="list" default="1" label="Show Ads" description="Should we include ads into the sitemap?">
<option value="0">Never</option>
<option value="1">Always</option>
<option value="2">In XML Sitemap Only</option>
<option value="3">In Site Sitemap Only</option>
</param>
<param name="@spacer" type="spacer" default="" label="XML Sitemap" description="Options for the XML sitemap only" />
<param name="cat_priority" type="list" default="-1" label="Category Priority" description="Set the priority for the categories">
<option value="-1">Use Parent Menu Settings</option>
<option value="0.0">0.0</option>
<option value="0.1">0.1</option>
<option value="0.2">0.2</option>
<option value="0.3">0.3</option>
<option value="0.4">0.4</option>
<option value="0.5">0.5</option>
<option value="0.6">0.6</option>
<option value="0.7">0.7</option>
<option value="0.8">0.8</option>
<option value="0.9">0.9</option>
<option value="1">1</option>
</param>
<param name="cat_changefreq" type="list" default="-1" label="Category Change frequency" description="Set the chage frequency for the categories">
<option value="-1">Use Parent Menu Settings</option>
<option value="always">Always</option>
<option value="hourly">Hourly</option>
<option value="daily">Daily</option>
<option value="weekly">Weekly</option>
<option value="monthly">Monthly</option>
<option value="yearly">Yearly</option>
<option value="never">Never</option>
</param>
<param name="ad_priority" type="list" default="-1" label="Ad Priority" description="Set the priority for the ads">
<option value="-1">Use Parent Menu Settings</option>
<option value="0.0">0.0</option>
<option value="0.1">0.1</option>
<option value="0.2">0.2</option>
<option value="0.3">0.3</option>
<option value="0.4">0.4</option>
<option value="0.5">0.5</option>
<option value="0.6">0.6</option>
<option value="0.7">0.7</option>
<option value="0.8">0.8</option>
<option value="0.9">0.9</option>
<option value="1">1</option>
</param>
<param name="ad_changefreq" type="list" default="-1" label="Ad Change frequency" description="Set the chage frequency for the ads">
<option value="-1">Use Parent Menu Settings</option>
<option value="always">Always</option>
<option value="hourly">Hourly</option>
<option value="daily">Daily</option>
<option value="weekly">Weekly</option>
<option value="monthly">Monthly</option>
<option value="yearly">Yearly</option>
<option value="never">Never</option>
</param>
</params>
</install>
com_amresurrected.php
- Code: Select all
<?php
/**
* @author Guillermo Vargas, http://joomla.vargas.co.cr
* @email guille@vargas.co.cr
* @version $Id: com_adsmanager.php 106 2008-02-15 21:46:56Z root $
* @package Xmap
* @license GNU/GPL
* @description Xmap plugin for AdsManager Component
*/
//defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/** Add support for AdsManager categories and ads to Xmap */
class xmap_com_amresurrected {
/** Get the content tree for this kind of content */
function &getTree( &$xmap, &$parent, &$params ) {
$database =& JFactory::getDBO();
$catid=0;
if ( strpos($parent->link, 'page=show_category') ) {
$link_query = parse_url( $parent->link );
parse_str( html_entity_decode($link_query['query']), $link_vars );
$catid = $xmap->getParam($link_vars,'catid',0);
}
$include_ads = $xmap->getParam($params,'include_ads',1);
$include_ads = ( $include_ads == 1
|| ( $include_ads == 2 && $xmap->view == 'xml')
|| ( $include_ads == 3 && $xmap->view == 'html'));
$params['include_ads'] = $include_ads;
$priority = $xmap->getParam($params,'cat_priority',$parent->priority);
$changefreq = $xmap->getParam($params,'cat_changefreq',$parent->changefreq);
if ($priority == '-1')
$priority = $parent->priority;
if ($changefreq == '-1')
$changefreq = $parent->changefreq;
$params['cat_priority'] = $priority;
$params['cat_changefreq'] = $changefreq;
$priority = $xmap->getParam($params,'ad_priority',$parent->priority);
$changefreq = $xmap->getParam($params,'ad_changefreq',$parent->changefreq);
if ($priority == '-1')
$priority = $parent->priority;
if ($changefreq == '-1')
$changefreq = $parent->changefreq;
$params['ad_priority'] = $priority;
$params['ad_changefreq'] = $changefreq;
xmap_com_adsmanager::getCategories($xmap,$parent,$catid,$params);
}
function getCategories ( &$xmap, &$parent, $catid=0,&$params ) {
$database =& JFactory::getDBO();
$mosConfig_absolute_path = JPATH_BASE;
$mosConfig_lang = & JFactory::getLanguage();
$my = &JFactory::getUser();;
$query = "SELECT * FROM #__adsmanager_categories WHERE `published`=1 and parent=$catid ORDER BY ordering";
$database->setQuery($query);
$rows = $database->loadAssocList();
$xmap->changeLevel(1);
foreach($rows as $row) {
$node = new stdclass;
$node->id = $parent->id;
$node->uid = $parent->uid . 'c' .$row['id'];
$node->browserNav = $parent->browserNav;
$node->name = $row['name'];
$node->modified = $xmap->now;
$node->link = 'index.php?option=com_amresurrected&page=show_category&catid='.$row['id'].'&text_search=&order=0&expand=0&Itemid='.$parent->id;
$node->pid = $row['parent']; // parent id
$node->priority = $params['ad_priority'];
$node->changefreq = $params['ad_changefreq'];
$xmap->printNode($node);
xmap_com_adsmanager::getCategories ( $xmap, $parent, $row['id'],$params);
}
if ( $params['include_ads'] ) {
$query = "SELECT id,name,ad_headline FROM #__adsmanager_ads WHERE `published`=1 and category = $catid";
$database->setQuery($query);
$rows = $database->loadAssocList();
foreach ( $rows as $row ) {
$node = new stdclass;
$node->id = $parent->id;
$node->uid = $parent->uid . 'a' .$row['id'];
$node->browserNav = $parent->browserNav;
$node->name = $row['ad_headline'];
$node->modified = $xmap->now;
$node->link = 'index.php?option=com_amresurrected&page=show_ad&adid='.$row['id'].'&catid='.$catid.'&Itemid='.$parent->id;
$node->priority = $params['ad_priority'];
$node->changefreq = $params['ad_changefreq'];
$node->tree = array();
$xmap->printNode($node);
}
}
$xmap->changeLevel(-1);
}
}
The xml file seems to work fine because I'm able to change the settings in the back-end.
Requesting the url to the sitemap still only give me my menu items and not my ads so the php file needs some tinkering.
Last edited by anti on Fri Sep 03, 2010 3:52 pm, edited 1 time in total.
- anti
- Fresh Boarder

- Posts: 3
- Joined: Thu Sep 02, 2010 6:19 pm
Re: Using Xmap+Ads Manager Resurrected
Okay, maybe you just need change the line:
xmap_com_adsmanager::getCategories($xmap,$parent,$catid,$params);
by
xmap_com_amresurrected::getCategories($xmap,$parent,$catid,$params);
...actually, replace all the instances of xmap_com_adsmanager by xmap_com_amresurrected
xmap_com_adsmanager::getCategories($xmap,$parent,$catid,$params);
by
xmap_com_amresurrected::getCategories($xmap,$parent,$catid,$params);
...actually, replace all the instances of xmap_com_adsmanager by xmap_com_amresurrected
-

guilleva - Administrator

- Posts: 1517
- Joined: Wed Sep 12, 2007 3:10 am
- Location: San José, Costa Rica
Re: Using Xmap+Ads Manager Resurrected
By changing all instances of adsmanager to amresurrected the xml parser reports an error.
My php file now looks like this.
It would be great if someone could explain the process that generates the xml file.
- Code: Select all
XML Parsing Error: no element found
Location: http://www.xxxxx.com/index.php?option=com_xmap&sitemap=1&view=xml
Line Number 22, Column 1:
My php file now looks like this.
- Code: Select all
<?php
/**
* @author Guillermo Vargas, http://joomla.vargas.co.cr
* @email guille@vargas.co.cr
* @version $Id: com_adsmanager.php 106 2008-02-15 21:46:56Z root $
* @package Xmap
* @license GNU/GPL
* @description Xmap plugin for AdsManager Component
*/
//defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/** Add support for AdsManager categories and ads to Xmap */
class xmap_com_amresurrected {
/** Get the content tree for this kind of content */
function &getTree( &$xmap, &$parent, &$params ) {
$database =& JFactory::getDBO();
$catid=0;
if ( strpos($parent->link, 'page=show_category') ) {
$link_query = parse_url( $parent->link );
parse_str( html_entity_decode($link_query['query']), $link_vars );
$catid = $xmap->getParam($link_vars,'catid',0);
}
$include_ads = $xmap->getParam($params,'include_ads',1);
$include_ads = ( $include_ads == 1
|| ( $include_ads == 2 && $xmap->view == 'xml')
|| ( $include_ads == 3 && $xmap->view == 'html'));
$params['include_ads'] = $include_ads;
$priority = $xmap->getParam($params,'cat_priority',$parent->priority);
$changefreq = $xmap->getParam($params,'cat_changefreq',$parent->changefreq);
if ($priority == '-1')
$priority = $parent->priority;
if ($changefreq == '-1')
$changefreq = $parent->changefreq;
$params['cat_priority'] = $priority;
$params['cat_changefreq'] = $changefreq;
$priority = $xmap->getParam($params,'ad_priority',$parent->priority);
$changefreq = $xmap->getParam($params,'ad_changefreq',$parent->changefreq);
if ($priority == '-1')
$priority = $parent->priority;
if ($changefreq == '-1')
$changefreq = $parent->changefreq;
$params['ad_priority'] = $priority;
$params['ad_changefreq'] = $changefreq;
xmap_com_amresurrected::getCategories($xmap,$parent,$catid,$params);
}
function getCategories ( &$xmap, &$parent, $catid=0,&$params ) {
$database =& JFactory::getDBO();
$mosConfig_absolute_path = JPATH_BASE;
$mosConfig_lang = & JFactory::getLanguage();
$my = &JFactory::getUser();;
$query = "SELECT * FROM #__adsmanager_categories WHERE `published`=1 and parent=$catid ORDER BY ordering";
$database->setQuery($query);
$rows = $database->loadAssocList();
$xmap->changeLevel(1);
foreach($rows as $row) {
$node = new stdclass;
$node->id = $parent->id;
$node->uid = $parent->uid . 'c' .$row['id'];
$node->browserNav = $parent->browserNav;
$node->name = $row['name'];
$node->modified = $xmap->now;
$node->link = 'index.php?option=com_amresurrected&page=show_category&catid='.$row['id'].'&text_search=&order=0&expand=0&Itemid='.$parent->id;
$node->pid = $row['parent']; // parent id
$node->priority = $params['ad_priority'];
$node->changefreq = $params['ad_changefreq'];
$xmap->printNode($node);
xmap_com_adsmanager::getCategories ( $xmap, $parent, $row['id'],$params);
}
if ( $params['include_ads'] ) {
$query = "SELECT id,name,ad_headline FROM #__adsmanager_ads WHERE `published`=1 and category = $catid";
$database->setQuery($query);
$rows = $database->loadAssocList();
foreach ( $rows as $row ) {
$node = new stdclass;
$node->id = $parent->id;
$node->uid = $parent->uid . 'a' .$row['id'];
$node->browserNav = $parent->browserNav;
$node->name = $row['ad_headline'];
$node->modified = $xmap->now;
$node->link = 'index.php?option=com_amresurrected&page=show_ad&adid='.$row['id'].'&catid='.$catid.'&Itemid='.$parent->id;
$node->priority = $params['ad_priority'];
$node->changefreq = $params['ad_changefreq'];
$node->tree = array();
$xmap->printNode($node);
}
}
$xmap->changeLevel(-1);
}
}
It would be great if someone could explain the process that generates the xml file.
- anti
- Fresh Boarder

- Posts: 3
- Joined: Thu Sep 02, 2010 6:19 pm
Re: Using Xmap+Ads Manager Resurrected
The plugin is now working. Attached it for others to use.
- Attachments
-
xmap_com_amresurrected.zip- Working plugin for AM Resurrected
- (2.34 KiB) Downloaded 342 times
- anti
- Fresh Boarder

- Posts: 3
- Joined: Thu Sep 02, 2010 6:19 pm
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 3 guests