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

How to get the image urls?

Discussion in 'Modules / Plugins / Modifications' started by Pierre, Nov 12, 2014.

  1. Pierre New Member

    Hi all,

    I'm developing a small module that adds some meta-tags to the item pages.

    So far I've managed to generate the tags that contain the item's url, title, description, address, price, etc. (thanks to $class_tpl->get_template_vars(..) ), but I'm struggling a bit with the images. What I need is to get the urls of the item's images (fullsize, no thumbnails).

    Any help would be mucho appreciated! ;)

    Greets
    --Pierre
  2. Mike-N-Tosh Owner

    It's the same as the thumbs except it's "photos" instead. (e.g. yoursite.com/photos/) Also the full images don't have the "small_" prefix as the thumbnails have. If you open the "viewlisting(2).tpl" file you can clearly see the url for both the thumbnail images as well as the url for the full images.
  3. Pierre New Member

    Ok, thanks.
    Not clear to me yet how I can access them from my hooks.php. Will have a closer look...
  4. Mike-N-Tosh Owner

    A few things that may help you in this matter, Pierre:
    1. Module development documentation:
      1. Modules documentaion
      2. Modulehooks documentation
    2. The viewlistings.php file has a modulehook around line #117:
      1. $modules->call_hook('viewlisting_end', $listing_rs); // Call any module functions
    3. The layout.tpl file has this modulehook in the <head>element for every page:
      1. {modulehook function="tpl_layout_head" options=""}
    If it were me, I would work with the hook in the viewlistings as it would be much more straight forward. In this particular case something like this:
    PHP:
    function logbe_metadata($listing_rs) {
      
    $i 0;
      
    $max count($listing_rs['data']);
     
      foreach (
    $listing_rs['data'] as $pic) {
          
    logbee_meta_array[$i]['title'] = '<meta blah, blah, blah...' .$listing_rs['data'][$i]['title']. '/>';
          ... do 
    more stuff ...
          ++
    $i;
      }
      
    $class_tpl->assign('lb_meta'$logbee_meta_array);
    }
    Then in your instructions, tell the user to insert "{$lb_meta}" in the <head> element of their main template file, "layout.tpl".
  5. Mike-N-Tosh Owner

    Also as a side note for development, although the smarty "get_template_vars()" is a great feature, it also adds additional processing for variables that have already been processed and available through our modulehook system. So, always check if the variables are already available in the modulehooks and use the smarty "get_template_vars()" when unavailable. Your users will appreciate it especially on a busy site.
  6. Pierre New Member

    Great, thanks a lot for the help! :)
    I took my inspiration from the 'canonical' module, but will go back to my keyboard... ;)
  7. Pierre New Member

    Excellent! It worked.
    Will test a bit more before I release the module.
    Thanks again for the hints!
    Mike-N-Tosh likes this.
  8. Pierre New Member

    Ok, I think the module's ready.
    I tried to access http://classifiedmods.com, but couldn't log in. How should I proceed in order to make my module publicly available?

Share This Page