Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Ads - ver: 1.0
#1
Random Ads Plugin

This is a simple and easy to use plugin for displaying random ads, banners, or other content on your website.

You have the ability to create and manage categories and add ads (or other content) to those categories. You can also edit/delete ads and categories.

Click Here To Go To Extend Plugin Page

Installation:
  • Drag the RandomAds.php file to your plugins directory and navigate to 'pages->Random Ads' in your Admin Panel.
  • There is a help page within the admin panel to explain how to include the random ads in your template.


Screenshots:

View All Ads:

[Image: view.jpg]


Add New Ad:

[Image: add.jpg]


Manage Categories:

[Image: categories.jpg]


Help:

[Image: help.jpg]


Any suggestions to improve usability/functionality are appreciated.
Reply
#2
How work it ???
I install, but show only title, not content.
Reply
#3
libygo Wrote:How work it ???
I install, but show only title, not content.
it would be nice to add editor ($ toolbar) in the textarea
Reply
#4
libygo Wrote:
libygo Wrote:How work it ???
I install, but show only title, not content.
it would be nice to add editor ($ toolbar) in the textarea

Thanks for your suggestion. I chose against this because I thought it might mess with formatting and spacing for the ads for inexperienced users.

Anyone else vote for ckeditor instead of plain textarea?
Reply
#5
mikeh Wrote:Thanks for your suggestion. I chose against this because I thought it might add some needed coding.
Anyone else vote for ckeditor instead of plain textarea?
But I do not understand how the plug-in work.
I create categories (news), after create ads (title, choose a category, writing content), and in template include: <?php display_ads('news'); ?>.
In site see only title, how show content?
Reply
#6
I could see myself using this to show random testimonials on a site...

mikeh Wrote:Any suggestions to improve usability/functionality are appreciated.

Here's some suggestions:
  • When saving an item and there is an error, such as no category chosen, all previously entered data is lost. Could you populate the form after the error with the previously entered data?
  • Since a user can't add a new item if there are no categories defined, it would be nice if the add new item form did not appear until there was at least one category. Instead there should be a message prompting the user to create a category first.
  • It would be nice to be able to change the category of an item after it's been saved.

None of these are biggies. Very nice for a first release!
Reply
#7
mikeh Wrote:
libygo Wrote:
libygo Wrote:How work it ???
I install, but show only title, not content.
it would be nice to add editor ($ toolbar) in the textarea

Thanks for your suggestion. I chose against this because I thought it might add some needed coding.
Anyone else vote for ckeditor instead of plain textarea?

I have uploaded ver: 1.0 to Extend
  • Changed textareas to use CKeditor
  • Fixed issue where theme function was pulling title instead of content
Reply
#8
libygo Wrote:
mikeh Wrote:Thanks for your suggestion. I chose against this because I thought it might add some needed coding.
Anyone else vote for ckeditor instead of plain textarea?
But I do not understand how the plug-in work.
I create categories (news), after create ads (title, choose a category, writing content), and in template include: <?php display_ads('news'); ?>.
In site see only title, how show content?

Just download the new copy and drag it to your plugins folder. It will immediately fix this problem. Sorry about that.
Reply
#9
Nice!!!
Plug-in opens great opportunities.
If in category 1 ads, does not want to work.
If some finish this plugin can replace components.
Good plugin, thanks.
Reply
#10
libygo Wrote:Nice!!!
Plug-in opens great opportunities.
If in category 1 ads, does not want to work.
If some finish this plugin can replace components.
Good plugin, thanks.

Ver: 1.1 Uploaded To Extend
  • Fixed issue preventing first category to be used in theme
Reply
#11
filupn Wrote:I could see myself using this to show random testimonials on a site...

mikeh Wrote:Any suggestions to improve usability/functionality are appreciated.

Here's some suggestions:
  • When saving an item and there is an error, such as no category chosen, all previously entered data is lost. Could you populate the form after the error with the previously entered data?
  • Since a user can't add a new item if there are no categories defined, it would be nice if the add new item form did not appear until there was at least one category. Instead there should be a message prompting the user to create a category first.
  • It would be nice to be able to change the category of an item after it's been saved.

None of these are biggies. Very nice for a first release!

In addition, for people using it on client sites for things other than ads, it might be nice to be able to call the items something else. Maybe an option to input a custom name, such as "Testimonials". With that it'd be perfect!
Reply
#12
filupn Wrote:
filupn Wrote:I could see myself using this to show random testimonials on a site...

mikeh Wrote:Any suggestions to improve usability/functionality are appreciated.

Here's some suggestions:
  • When saving an item and there is an error, such as no category chosen, all previously entered data is lost. Could you populate the form after the error with the previously entered data?
  • Since a user can't add a new item if there are no categories defined, it would be nice if the add new item form did not appear until there was at least one category. Instead there should be a message prompting the user to create a category first.
  • It would be nice to be able to change the category of an item after it's been saved.

None of these are biggies. Very nice for a first release!

In addition, for people using it on client sites for things other than ads, it might be nice to be able to call the items something else. Maybe an option to input a custom name, such as "Testimonials". With that it'd be perfect!

Good suggestion, i'll try and get to that tonight. My intentions were to make a random banner plugin but your right, it can be randomized anything.
Reply
#13
Again, awesome work, Mike! Smile
Reply
#14
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?
Reply
#15
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
Reply
#16
Hi, thanks for the plugin.

Please add the function to enable/disable the ads Smile
Reply
#17
You can turn off the ads just by disabling the plugin in the GS admin.
Reply
#18
Or, do you mean enabling/disabling ads on an individual basis? Yes, I agree that would be useful.
Reply
#19
First of all thanks for this great plug-in, I was looking for one like this.

mikeh Wrote:
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
A little bit of help on that one:

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.
Reply
#20
Hi guys
I cannot get the plugin working correctly. All tags inside of an advertisement's text seem to be processed by PHP's htmlspecialchars() function. That's why none of ADs are shown properly. But everything's OK if I enter regular text without HTML tags inside.
Can anyone help?
Hail to get-simple developers!
Reply
#21
reff Wrote:Hi guys
I cannot get the plugin working correctly. All tags inside of an advertisement's text seem to be processed by PHP's htmlspecialchars() function. That's why none of ADs are shown properly. But everything's OK if I enter regular text without HTML tags inside.
Can anyone help?
There is a bug which adds \ before " in the html tags (with each edit it adds many more) thus messing up the entire code. I have tried to to use it to show random images but it messes up all the code and the images don't show up. If I manually edit and correct the mistakes in the file random_ads.xml, everything works fine but I need to know how to fix this bug since the moment I add an Ad it will mess up the code again.
Reply
#22
andyash Wrote:There is a bug which adds \ before " in the html tags (with each edit it adds many more) thus messing up the entire code. I have tried to to use it to show random images but it messes up all the code and the images don't show up. If I manually edit and correct the mistakes in the file random_ads.xml, everything works fine but I need to know how to fix this bug since the moment I add an Ad it will mess up the code again.

Oh, good, then it's not just me. I had this issue (or something really similar) with the events plug-in as well. IMG and link code get munged with the quotes and they show an error on my public-facing pages (you can view the url for an image and see clearly why it didnt work). I tried just the local path for images and full URLs and didnt have much luck. And when I return to edit an ad I've tried to put an image in (and saved it) the editor hangs.

I wondered if there was something in the way the plugin calls the editor or processes the results I could change, I mean, if the page editor also uses CKEditor and it doesent have this problem, can I just use the same code (more or less) inside the plugin?
Reply
#23
andyash Wrote:
reff Wrote:Hi guys
I cannot get the plugin working correctly. All tags inside of an advertisement's text seem to be processed by PHP's htmlspecialchars() function. That's why none of ADs are shown properly. But everything's OK if I enter regular text without HTML tags inside.
Can anyone help?
There is a bug which adds \ before " in the html tags (with each edit it adds many more) thus messing up the entire code. I have tried to to use it to show random images but it messes up all the code and the images don't show up. If I manually edit and correct the mistakes in the file random_ads.xml, everything works fine but I need to know how to fix this bug since the moment I add an Ad it will mess up the code again.

can you please provide me an example of coding where it does this too?
Reply
#24
I've rewrote the file which now works as far as I know good. Futher I changed the XML-file, I know find it more structured but that's my opinion. There is also an option to change the amount of ads you want to show, but they don't show correct in all layouts. So you may have to make some changes by yourself if it doesn't show correctly. The only thing you have to do is change $number_ads and it shows as many ads you want. I hope it works correctly now, the problem above is also corrected in this file.
Reply
#25
The plugin works fine! Thanks ...

I miss only the timer, now with every new page load or refresh to get a new ad. Suppose I have 3 seconds to show an advertisement and then the following should be shown.

This is already possible by modifying code in the plugin or must be built. Is a missed option.
Reply




Users browsing this thread: 2 Guest(s)