Results 1 to 11 of 11

Thread: Need help with new plugin

  1. #1
    Join Date
    Nov 2007
    Posts
    227

    Default Need help with new plugin

    O.K. I give up and need help with a plugin I am currently working on. I have been trying to get this to work correctly for 2 weeks and I need some fresh eyes. Hopefully Bruce, one of the programmers, or someone else can help me solve this problem. This is a difficult one for me to put into words, by I'll give it a shot.

    I am creating a banner rotation script from an idea I originally got from echo@. It stores the banner information in the database. When called for the first time, it records the users IP and the banner they were shown. The next time the page is called, it checks the database and selects a different banner than the one just displayed and updates the dabase with the new banner ID. It works flawlessly if I attach it to one html hook. However, if I attach it to more than 1 hook, it does not work correctly. Hopefully that is not too confusing, but if it is have a look for yourself.

    INDEXU Deluxe - Link Management

    On the front page, I have it attached to the hook "hook_html_index_welcome". You can refresh the page a million times and because I have 2 banners being displayed, it will display a different banner each time.

    Now I also have it attached to the hook "hook_html_add_form_begin". Click on "Add a Listing" at the top of the page. You will see the banner near the top. Now refresh the page a couple of times. The banner is not rotating. Why?

    If I remove either hook from the code, it displays perfectly on the 1 remaining hook. No matter which hooks I attach it to, if I have more than 1, it has this bug.

    I already have the script set up to add, edit, and delete banners from the admin area. I would like to add the ability to add hooks from the admin area as well. I want to be able to display the banners from any hook location on multiple pages. With this bug, this plugin is almost useless unless you only want to attach it to 1 single file.

    Please help me figure this one out. This could be a very useful plugin. If you need it, I can send the files so you can look it the code. I don't think it's in my code though, I think it's in the way IndexU handles the hooks in the plugins.

    Regards
    Wayne
    For questions related to any mods I developed, please contact me by pm or email at webmaster [at] scriptdragon [dot] com

  2. #2
    Join Date
    May 2007
    Location
    NJ, United States
    Posts
    1,651

    Default

    Wayne...

    I know nothing about this... But could it have anything to do with caching???
    FSGDAG | IndexU Hosting | Owner
    Website | NiceCoder Script Hosting and More! | Web4URL is For Sale!
    Follow Us On Twitter | FaceBook Profile | YouTube Videos

  3. #3
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    On the add.php the banner DID change for me. For the first couple of refreshes I saw the bash bosh banner 2 or 3 times and then the jbholcombe banner. Then I refreshed again and saw the bash bosh banner 2 times and then the jb banner once, after that it is now going back and forth.

    I'm not a programmer, and you can gladly talk to the programmers about this, but I think the issue is related to the php session.

    Perhaps what you need to do is to write a cookie as well. the cookie gets written with the LAST banner ID, the script checks it, compares it to the database and then writes the second banner ID. It keeps going until it reaches the end and starts the cycle back at the first banner.

    Using this method, you could have zones (zone1=top, zone2=side etc) and you could count then all off and rotate all of them.

  4. #4
    Join Date
    Nov 2007
    Posts
    227

    Default

    The add.php page banner is occasionally changing but giving strange results in the database. When banner 1 displays, it enters banner 2 in the database and vice versa.

    Also, if I clear the template_c folder after each refresh, it works perfectly. So FSGDAG may be somewhat close in saying that it has something to do with caching.

    Using cookies for this is a great idea, I will try that if I get this problem solved.

    I plan on using zones so you could set more than 1 banner per page.

    What stumps me is why does it work perfectly when attached to 1 hook, but then gets this bug when I attach it to 2 or more hooks? If I remove it from the "hook_html_index_welcome" it works perfectly on the add.php page.

    Regards
    Wayne
    For questions related to any mods I developed, please contact me by pm or email at webmaster [at] scriptdragon [dot] com

  5. #5
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    Perhaps because plugins are cached by default (I don't know how to disable that) so that IndexU will run faster without having to include files each time a plugin is loaded.

  6. #6
    Join Date
    Aug 2008
    Posts
    49

    Default

    you could solve your problem by store your banner contents in the variable before you send to hook_html. for example

    $idx_banner_html = '<div><%\$random_banner%></div>';
    then the $idx_banner_html sent to hook_html, you also send the $random_banner to template by hook_php or your plugin script that handle it.

    that is my logic. if you dont mind, could you share your script? may be i could help.

  7. #7
    Join Date
    Nov 2007
    Posts
    227

    Default

    Of course I can share it. I appreciate the help. I have attached the entire plugin to this post. The hooks for displaying the images/banners are on lines 147 & 178 of the image-rotator-plugin.php file.

    I tried storing the banner contents in a variable before calling using something similar to:

    Code:
    $banner_html = file_get_contents($indexu->config['plugin_path'] .'/image-rotator/template/rotator.html');
    Then I attached it to the hooks with:

    Code:
    $plug->SetHtmlHook('hook_html_add_form_begin', $banner_html);
    $plug->SetHtmlHook('hook_html_index_welcome', $banner_html);
    I have tried a million different ways of doing that entire function. It was written, re-written, re-written, and on and on. I hope some fresh eyes will help.

    If anyone else would like to try the plugin out, feel free to install it. Just keep in mind that it is not production ready and has not had extensive testing. If you want to try it out and give me your feedback or feature requests, that would be great. Please do not use it on a live site, use a test installation to test it.

    After installing the plugin, there will be an added menu on the left in the admin area. The menu allows you to add, edit, and delete images. The only required field is the image itself, all others are optional.

    Just remember, it's maybe only 70% done. I want to solve this problem before I waste my time on adding more features and cleaning up the code.

    Regards
    Wayne
    Attached Files Attached Files
    For questions related to any mods I developed, please contact me by pm or email at webmaster [at] scriptdragon [dot] com

  8. #8
    Join Date
    Oct 2007
    Location
    UK Essex
    Posts
    591

    Default

    Nakos did you find the solution?

    BTW this is a very very cool plugin even if it is 70% complete
    ____________________________
    http://www.articleconveyer.com
    Give Your Articles Exposure



  9. #9
    Join Date
    Aug 2008
    Posts
    49

    Default

    sorry, i have long time didn't visit this thread, i just downloaded the plugin.

    i'll try.

  10. #10
    Join Date
    Aug 2008
    Posts
    49

    Default

    hello,

    i have tried, there is weakness on hook_php_init, that is run before filtered, perhaps the process catched by RunPreFilter. then i tried to set hook on hook_php_add_begin, it work out.

    for next version, i have added some hooks on lib.filter.php, you could download it from svn [http://nicecoder.com/svn/index.php?act=changeset&id=973].

    if you have got the latest svn, let modify your code
    from
    $plug->SetHook("hook_php_init","PL_DisplayRandomImage" );
    to
    $plug->SetHook("hook_php_after_prefilter","PL_DisplayRan domImage");
    Last edited by nakos; 02-03-2009 at 01:00 AM.

  11. #11
    Join Date
    Nov 2007
    Posts
    227

    Default

    Thank you nakos for helping out. I quit working on the plugin because I could not get this worked out, hopefully that will do the trick. Now I will see if I can finish it.

    Regards
    Wayne
    For questions related to any mods I developed, please contact me by pm or email at webmaster [at] scriptdragon [dot] com

Similar Threads

  1. Do you use the VB plugin?
    By Bruceper in forum Customers Lounge
    Replies: 16
    Last Post: 03-13-2009, 12:47 AM
  2. Plugin HELP
    By Rockyuk in forum INDEXU DELUXE v1.x
    Replies: 3
    Last Post: 01-01-2009, 11:59 AM
  3. More plugin hooks please
    By mpdaddy in forum INDEXU DELUXE v1.x
    Replies: 28
    Last Post: 11-05-2008, 12:56 AM
  4. Plugin Ideas
    By echo@ in forum INDEXU DELUXE v1.x
    Replies: 1
    Last Post: 10-06-2008, 02:09 PM
  5. Indexu to Vb plugin
    By echo@ in forum INDEXU DELUXE v1.x
    Replies: 1
    Last Post: 09-26-2008, 04:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •