V4.2.x Using {$entry.class} in userbrowselistings.tpl

Discussion in 'Modules / Plugins / Modifications' started by freeze2, Dec 28, 2011.

  1. freeze2 Customer

    Is there a simple way to use {$entry.class} in the userbrowselistings.tpl ?

    I see that it is not an assigned variable for this template, but would be very handy to use it to uniquely style an "upgrade" via the userbrowselistings.tpl

    Is there possibly another way to see what the "upgrade" status is of your listing without going through the upgade process?

    Thanks very much!
  2. Mike-N-Tosh Developer & Moderator

    If it were me, I would just make a smarty plugin, you already have the variable in the template for each listingid. Have the output set to spit out the class as you would want it. Then in the template do something like:

    <div{myclassplugin id=xxx}> <!-- xxx=whatever the listingid variable is -->
    existing line code in the template
    </div>

    Your plugin outputs " class="featured....." or "" if there isn't an upgrade.
  3. freeze2 Customer

    Now if only I was a programmer

    I did this simple modification to add thumbnails to userbrowselistings and was hoping this task might be just as simple.
  4. Mike-N-Tosh Developer & Moderator

    Perhaps it's time to hire one. I've noticed that you certainly seem to want to do a lot of custom programming and such.

    68 Classified professionals
  5. freeze2 Customer

    But I have tried to hire someone ^^...with no success

    Seriously though...pm me a price on this (no plugin if possible) I have no problem paying for services
  6. John Snyder Staff

    You could manually assign a class using the existing smarty logic for upgrade or renewal

    HTML:
    {foreach from=$results item="entry"}
            <tr class="{if $entry.oStatus == 3 || $entry.oStatus==4}normal{elseif $entry.renew && $entry.renew_allowed == 'Y'}renew{elseif $entry.renew_allowed == 'Y'}upgrade{/if}">
             ....
            </tr>
    {foreachelse}
            ....
    
  7. freeze2 Customer

    Thanks John for your direction.

    I did some testing in userbrowselistings.tpl with your exact example and for some reason I was only able to output "upgrade" regardless if the listing was featured or not.
  8. John Snyder Staff

    Maybe I misread, I thought you just wanted to apply a different style if it was an upgrade or renewal? Where does featured come in to this?
  9. seymourjames All Hands On Deck

    I am getting a little more confused because the upgrade link in userbrowselistings seems to show even if the advert is already featured and when clicked does nothing (well redirects to userindex.php)

    This does not appear to be a bug but it would seem like a design decision. Really, an enhancement would be a message to say that this advert is already featured, bold or highlighted. And this comes back to the original request. Perhaps a column in userbrowselistings is required to give the type of advert it is (std, bold, highlighted or featured). Then to cover the possible upgrades the upgrade button should offer those available (e.g. a featured advert can be bolded, etc).

    Personally I think it is already over complicated. I would only support standard and featured adverts. Life would get simpler and the logic would also be easier to understand.
  10. freeze2 Customer

    Yes, this is exactly what I was hoping to achieve...a way for the user to know which of their listings are featured etc. via userbrowselistings

    My thought was that if {$entry.class} would work in this template, I could easily assign a class to possibly the title or cell so that the user could differentiate between regular listings or featured listings etc. (adding a new column for this would also work great)

    Sorry John, after re-reading my original post. I see, that I probably didn't explain things properly.
  11. John Snyder Staff

    You need to add the featured column to the query, and it will be assigned. Then you just need to do something based on {$featured}

    includes/classes/kernel/Listings.php around line 757 in the getListingsForMember method:

    PHP:

    $where 
    $modules->call_hook('userbrowselistings_where''');
    $sSQL "SELECT l.featured,l.id,l.t....";
    templates/default/user/userbrowselistings.tpl

    HTML:
    {foreach from=$results item="entry"}
        <tr class="{if $entry.featured == 'Y'}featured{/if}">
             ....         
        </tr> 
    {foreachelse}
         ....
    
  12. seymourjames All Hands On Deck

    That would be a nice feature if you excuse the pun for a future version.
  13. Mike-N-Tosh Developer & Moderator

    I don't see how the module hook, helps with the requested function as this would only input an SQL "WHERE" statement at the end of the existing sql query which still does NOT include a search within the listings table for any of the upgrade options, it only gets whether the options are available to the listing from the orders table. Unless I am missing something which I may be. The orders table simply copies whether these upgrades are individually available to the listing copying the boolean fields (Y/N) from the products table. It does NOT store whether the listing itself has actually used any of the available upgrades.

    The existing query in the getListingsForMember function is only fetching these fields from the listings table:
    Code:
    $sSQL = "SELECT id,title,section,price,display,hitcount,dateadded,expiration,orderID
    The rest of the query is from the orders table from the LEFT JOIN portion of the query. Again, perhaps I'm missing something and there is a way to add an additional search within the same query to go back and retrieve the columns for featured, pBold and pHighlighted from the listings table I don't see how this module hook helps.

    Now I could see how a module hook might help in this after the "real search" is done further down within the "while method" either before or after line #694:
    Code:
    $results[] = $row
    Then you could take the existing array and go back and do the search for each listing $id to fetch the upgrade fields for the listing and push those results into the existing array. Then those fields would be assigned to the template from the userbrowselistings.php within the array assign to results.
  14. John Snyder Staff

    I've added the first image, featured, bold, highlight for the next release (4.2.5), but didn't use them in the template because it gets very crowded in there. If you want to use them you will have template access to those variables.
  15. John Snyder Staff

    The hook was already there, I just included it in the code for some context to help locate the query string. Here is how I modified it for the extras fields:

    Add this to the query string:

    Code:
    l.featured,l.pBold,l.pHighlighted
    Added this further down in the results loop:

    PHP:
    $row['image'] = $this->getListingSingleImage($row['id']);
  16. freeze2 Customer

    This is great information...thanks to all!
  17. seymourjames All Hands On Deck

    Well done John. I think it will be a nice touch even if it is just a key symbol or color code to save on space.
  18. freeze2 Customer

    I couldn't agree more, I've had a little time to play around with some different possibilities and this feature is HUGE!

    Thanks again!
  19. Mike-N-Tosh Developer & Moderator

    One of the "features" that I've had many requests for from my clients is the navigation for the whole user account section/pages. The links only show in the user index page. I took that code from the user index template and placed it in a separate file and then used a smarty include file for each of the user pages so that they wouldn't have to go back to the Account link in the main navigation each time to then click on the link for another user account page.
  20. freeze2 Customer

    Excellent Mike! One of the things I've learned about the 68C script is that it is incredibly versatile, just like this example.

Share This Page