2011-09-08, 05:04:47
First of all thanks for this great plug-in, I was looking for one like this.
Replace the old function display_ads:
With my new one and it should be working.
I'm also working on an option to show more than just one ad on a page.
mikeh Wrote:A little bit of help on that one:libygo Wrote:Hi!
Is problem:
If create category and in category create one ad, plug-in dont work.
If create two ads, work good.
You can change this?
I will fix this issue. For now, I suggest if you want only 1 ad in a category, to make 2 identical ads.
Thanks
Replace the old function display_ads:
Code:
function display_ads($category)
{
$ad_count = 0;
if(file_exists(ADSDATAFILE))
{
$category_file = getXML(ADSDATAFILE);
}
foreach($category_file->category as $category_name)
{
if($category_name->categoryname == $category)
{
foreach($category_name->ad as $ad_counter)
{
$ad_count++;
}
$category_array = xml2array($category_name);
$ad_count = rand (0, ($ad_count - 1));
echo $category_array['ad'][$ad_count]->contents;
}
}
}
With my new one and it should be working.
Code:
function display_ads($category)
{
$ad_count = -1;
if(file_exists(ADSDATAFILE))
{
$category_file = getXML(ADSDATAFILE);
}
foreach($category_file->category as $category_name)
{
if($category_name->categoryname == $category)
{
foreach($category_name->ad as $ad_counter)
{
$ad_count++;
}
$category_array = xml2array($category_name);
if($ad_count===0){
echo $category_array['ad']['contents'];
}else{
$ad_count = rand (0, ($ad_count));
echo $category_array['ad'][$ad_count]->contents;
}
}
}
}
I'm also working on an option to show more than just one ad on a page.