Fork me on GitHub

New block for the Banner module... Need some array guidance.  Bottom

  • I'm trying to create a new display block for the Banners module based off of Presentation Slide from DynamicDrive.com. Based off of my rusty knowledge of PHP and arrays, and such, I'm figuring I need to write a function to return the needed arrays, so I'm building off of the banners_users_display() function. But it's been a while. If I'm not mistaken, what I need to do is build two arrays, the first an array of the image urls, and second the click urls to pass to the template. I just can't recall how to do it anymore.

    --
    Home Page | Find on Facebook | Follow on Twitter
  • icon_biggrin shouldn't be too hard. You can make a PHP array in you PHP function and fill it with your images:

    Code

    $banners = array();
    foreach .. {
    $banners[] = array('image' => $imagename, 'imageurl' => $urltotheimage);
    }


    You can then assign this var to the template

    Code

    render->assign('banners', $banners);


    and then use it in the template where you call the DD script also with a loop, not written out entirely, but I hope you get the idea (check out other templates for the exact lang constructions):

    Code

    "foreach $banners as $banner"
    dropimage[0] = $banner.image;
    dropurl[0] = $banner.imageurl;
    "endforeach"


    --
    campertoday.nl, Module development, Dutch Zikula Community
  • I think that's what I ended up doing in the PHP, or something similar at least. I'll play with the templates later, it's too late now :)



    edited by: HalbrookTech, datetimebrief

    --
    Home Page | Find on Facebook | Follow on Twitter
  • Alright, got that one working, unfortunatly, I decided on a different rotation script, and to use it, I need to be able to tell when I've got the last item in the array, because the data array for this script there needs to be a comma after all but the last. I found some info on the Smarty modifier for .last, but how to I use it in Render?

    --
    Home Page | Find on Facebook | Follow on Twitter
  • argh, I figured it out, had it working, decided to try and tweak something else, and now it broke and I can't figure out what I did to it.. Gotta remember to save a working copy before I start changing.

    --
    Home Page | Find on Facebook | Follow on Twitter
  • And evidently it had something to do with there being 2 blocks active at the same time, working again. Got more work before i can release it as some stuff is currently hard coded to the specific site but you can see it in action at http://new.peopleschurchvancouver.org on the main page.

    I need to make the dimensions configurable, and I'd like to bring several different methods in to one block, rather than right now i have 1 that does the above referenced style, and the one that's active.

    --
    Home Page | Find on Facebook | Follow on Twitter

This list is based on users active over the last 60 minutes.