1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Plug in to display ads for wpmu's

Discussion in 'Blogging' started by tomt, Apr 12, 2009.

  1. tomt

    tomt Newbie

    Joined:
    Aug 24, 2007
    Messages:
    25
    Likes Received:
    2
    I am looking for a plugin that will display different ads on different blogs in the same wpmu install. I haven't found exactly what I am looking for yet. Perhaps I am not entering the right search terms. I can find all sorts of plugins for adsense type ads. If needed, I can adapt two or more plugins to accomplish this.

    Here is an example of what I am talking about.

    Domain: mywpmuinstall.com

    Blog One: dogtraining.mywpmuinstall.com

    I want to display either banner ads and/or text ads. Can not be contextual. I want to enter the exact code that is provided to me, say from LinkShare. Or plugin displays ad based on a keyword, in this case - dog training.

    Blog Two: babyshowers.mywpmuinstall.com

    Same deal only keyword(s) would pertain to - baby showers.

    Blog Three to Whatever - differnt ads - different keyword(s).

    All the plugins I have looked at so far are based on contextual ads or a single wordpress install. Has anyone seen a plugin(s) for wpmu that will do this?

    Thanks
     
  2. tomt

    tomt Newbie

    Joined:
    Aug 24, 2007
    Messages:
    25
    Likes Received:
    2
    Ok, it's been a couple of days since I posted this. Either there is no interest in this or no one knows of a plugin that does it. Regardless, I made something that works, although it is not a plugin. Maybe someone who is smarter than me in php programming can turn it into one.

    First I created a new table in the wpmu database using the following code

    Code:
    CREATE TABLE `yourDatabaseName`.`ads` (
    `id` BIGINT NOT NULL AUTO_INCREMENT ,
    `blog_id` BIGINT NOT NULL ,
    `my_ad` LONGTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
    PRIMARY KEY ( `id` ) 
    ) ENGINE = MYISAM 
    Substitute your wpmu database name for yourDatabaseName in the above code. I ran this code in phpmyadmin. I then ran the following code

    Code:
    INSERT INTO `yourDatabaseName`.`ads` (
    `id` ,
    `blog_id` ,
    `my_ad` 
    )
    VALUES (
    NULL , '2', 'this is a test'
    );

    Then I created the following function and saved it as adfunction.php. I placed this file into my theme folder.

    Code:
    <?php
    function show_ad() {
    // Query to select an int column
    $query = "SELECT * FROM `ads` WHERE blog_id ='".$blog_id."'";
    $result = mysql_query($query);
    $array = mysql_fetch_assoc($result);
    
    // Echoes: string
    echo $array['my_ad'];
    }
    ?> 
    Now you have to edit the following theme pages - index.php and single.php

    Copy this code near the top of each

    Code:
    <? include "adfunction.php";?>
    Now were ever you want the ad to show up on your page place this code

    Code:
    <?php show_ad(); ?>
    Of course you could do this in the sidebar as well, but I wanted my ads to show up in the body of the page.

    That's it. I enter the ad code through phpmyadmin for each blog. This works with the clickbank adsense like ads, store stacker widget code. Actually anything you place in the my_ad field in the database will display, including html code.

    Now maybe someone can take this and make a nice friendly user interface. Maybe even expand on this where two or more ad blocks could be displayed at different spots on a page.
     
  3. cassanova

    cassanova Newbie

    Joined:
    Apr 8, 2009
    Messages:
    45
    Likes Received:
    12
    it's so clearly.. thanks..
     
  4. projext

    projext Regular Member

    Joined:
    Jan 23, 2009
    Messages:
    240
    Likes Received:
    53
    Occupation:
    Freelance SEO Consultant and average internet mark
    Location:
    Manchester, Uk
    I'd be interested in this and you have clearly spent some time on it..well done.

    As you say..can anyone turn this into a plugin?
     
  5. tomt

    tomt Newbie

    Joined:
    Aug 24, 2007
    Messages:
    25
    Likes Received:
    2
    The code for adfunction.php above is wrong. I typed the code by copying from my test server's monitor which is behind where I sit here. I didn't catch that I actually had the blog id hard coded in there on my test server. I am not a php programmer. I can look at what others have done and experiment. This afternoon when I was uploading the files to a "real" wpmu install is when I noticed I had an error. Below is the correct code.

    Code:
    <?php
    function show_ad() {
    // Query to select an int column
    global $blog_id;
    $query = "SELECT * FROM `ads` WHERE blog_id ='.$blog_id.'";
    $result = mysql_query($query);
    $array = mysql_fetch_assoc($result);
    
    // Echoes: string
    echo $array['my_ad'];
    }
    ?> 
    
     
  6. dynamicvb

    dynamicvb Regular Member

    Joined:
    Sep 2, 2007
    Messages:
    389
    Likes Received:
    185
    I would think you would want to use something like openads or a similar script so you could control all the ads from a backend app.
     
  7. tomt

    tomt Newbie

    Joined:
    Aug 24, 2007
    Messages:
    25
    Likes Received:
    2
    Well sure I am all for that. I never could find anything that worked wpmu. Does openads work with wpmu? Doing a google search I found a download link for wp openads, but the link page didn't have anything to do with openads. Another link led to OpenX Ad Server, but that looked to sophisticated for what I want to do. Where would you find what you are talking about?
     
  8. dynamicvb

    dynamicvb Regular Member

    Joined:
    Sep 2, 2007
    Messages:
    389
    Likes Received:
    185
    Looks like they may have changed it. Its not really for Wordpress but a full fledged ad serving system May be more than you want, but its very powerful. If you have fantasio in your hosting package there is probably a copy in there to install in a couple of minutes and play around with.