MODIFICATION: Display your extra fields on the showlistings.tpl page

Discussion in 'Modules / Plugins / Modifications' started by cwp, Mar 2, 2008.

  1. Lhotch curmudgeon

    The SEO mod should have no effect on getting an extra field. I beleive its not working because your not quite following what I said above. I admit, unless you know what you are doing the original post doesnt make any sense. When you attempt thses kinds of mods you really should have a basic understanding of what you are doing because if you dont you can waste a lot of time and suffer a lot of headaches.

    In the listings.php file you have a bunch of different functions.

    Think of the listings.php file as a tool box and each function within the file (ie toolbox) performs a certain job. You have different tools for different jobs and just like that, functions each do a certain task. You can reach into your tool box full of tools and just use a single tool. Or you can combine tools (ie 2 different sized wrenched, one for the bolt head and one for the nut).

    Within the listings.php file is a function called "getExtraField". This function (ie tool) takes the ID of an ad and an ID of an extra field and in turn gets the value stored in that extra field from the database for the ad.

    When you goto your site, click on a category with ads in it the script file category.php is run. Within that script the function "getAllListings" is run. This is one of the tools in your toolbox(ie listings.php)

    $list=$Listings->getAllListings($options, $pageNum, MAX_ROWS_SEARCH);

    What the above line does is pass some values to the function "getAllListings", the function is run and the data it collects sits in the variable "$list".

    Now if we take a closer look at the function "getAllListings" we can see that it queries the database and collects all the ads meeting the parameters that were passed to the function when it was called.

    Now, in your post above you said you added "$row['extrafield'] = $this->getExtraField($row['id'], 4);" to the function "getExtraField" just after the line "$row['status']=$row['display'];".

    From what I am seeing in my code, there is no line of code "$row['status']=$row['display'];" in the function "getExtraField". so im not sure where you put this. As I said above that line doesnt go in the "getExtraField" but in the "getAllListings".

    The "getExtraField" function is not called from category.php and adding the line to it above like you did means the function is just calling itself but in order for it to even do that (which we dont want in the first place) it would have to be called from somewhere else, which it isnt.

    So, long store short find the following line in listings.php

    function getAllListings($options, $current_row, $max)

    toward the end of that function find the following....

    Code:
    while ($row=$result->fetch()) 
    {
    	$row['id']=$row['id'];
    
    and make it look like this.....

    Code:
    while ($row=$result->fetch()) 
    {
    	$row['id']=$row['id'];
            $row['extrafield'] = $this->getExtraField($row['id'], 4);
    
  2. CHRD Member

    thanks, Iv got it working.

    So I just add more lines

    $row['extrafield'] = $this->getExtraField($row['id'], 2);

    $row['extrafield'] = $this->getExtraField($row['id'], 6);

    to use multi extra frields with {$entry.extrafield2} {$entry.extrafield6}
  3. Lhotch curmudgeon

    Almost.

    $row['extrafield'] is an element in array. If you do the above like you have it $row['extrafield'] would hold the value of field 2 then when you called it again $row['extrafield'] would be overwritten with the value of field 6.

    You need to change the name of the variable, which you did in the smarty variable section.

    Your would want to do something like this....

    $row['extrafield2'] = $this->getExtraField($row['id'], 2);

    $row['extrafield6'] = $this->getExtraField($row['id'], 6);

    and then call them in the template with....
    {$entry.extrafield2}
    {$entry.extrafield6}
  4. CHRD Member

    OK great

    where do I need to edit to use the extra field info in the layout.tpl and view listings.

    Iv just found {$extrafields.0.value}

    change 0 to the id of the field {$extrafields.4.value}

    this also works in the layout temp so you can add your keywords in title, meta and around viewlistings

    Sorry if this is old news just that I found it hard to find the info in the forum
  5. bobbydiva Customer

    How do you remove fields from the listing view? I want to get rid of country.
  6. Mike-N-Tosh Developer & Moderator

    Please stop posting the same question in different threads. In addition, you should start a new thread and not tag on to an existing one.
  7. bobbydiva Customer

    Sorry,
    back to this topic

    In my Listings.php there are two instances of
    $row['status']=$row['display'];

    Do I put
    $row['extrafield'] = $this->getExtraField($row['id'], );

    after both?
  8. bobbydiva Customer

    Actually nevermind, I understand now, however I know it says place {$entry.extrafield} where you like in showlistings.tpl - but A) I'm unsure where is appropriate, and B) wherever I put it nothing shows up anyway.

    I can't figure out how to incorporate {$entry.extrafield} in to this sort of code:

    {if $sDisState == "Y"}
    <td{if $entry.class<>""} class="{$entry.class}"{/if}>{$entry.state}</td>
    {/if}
  9. seymourjames All Hands On Deck

Share This Page