provide Modify Listing link on viewlisting page

Discussion in 'Technical Support' started by business, Jul 2, 2009.

Thread Status:
Not open for further replies.
  1. business Customer

    I am trying to provide a link on the viewlisting.tpl to allow the owner of the listing to modify the listing.

    Code:
    {if $smarty.session.username=$username}<a href="/usermodifylisting.php?view={$view}">Modify Listing</a>{/if}
    The idea is: when the owner of the listing is viewing it, we provide a link to Modify it.

    But the above code does not work.. I get the following error:
    what am i doing wrong? also, is there any risk in providing this feature.
    thanks.
  2. Lhotch curmudgeon

  3. business Customer

    i was able to do this:

    Code:
    {if "`$smarty.session.username`==`$username`"}<a href="/usermodifylisting.php?view={$view}">Modify Listing</a>{/if} 
    but the Modify Listing link is displayed on all listings pages... my thinking was display the link if the listing owner is equal to logged-in user.
  4. Lhotch curmudgeon

    Have you checked the contents of your variables to begin with?

    In other words if you put the following in a template to se what they provide what do you get?

    {$smarty.session.username}

    {$username}
  5. business Customer

    yes. I had already done that before I started writing the IF statement.

    {$smarty.session.username} outputs the username of the logged-in user / current user

    {$username} gives the username of the owner of the listing (i am using this in viewlisting2.tpl)


    So, if the above two are equal/same, I am trying to put the Modify Listing link.
  6. John Snyder Staff

    Not sure why you are quoting and backticking stuff. So this doesn't work?

    HTML:
    {if $smarty.session.username == $username}
    <a href="/usermodifylisting.php?view={$view}">Modify Listing</a>
    {/if}
  7. business Customer

    works great.
    i swear i tried the same syntax before and got error... maybe i missed something .. thanks to the two of you...
  8. Lhotch curmudgeon

    from the smarty docs...

    Upon closer inspection of his original post however only has a single equal sign.
  9. John Snyder Staff

    Thanks for the doc Larry, I was aware you could use quotes, just wasn't sure why he was using them in that instance as it wasn't necessary.
  10. Lhotch curmudgeon

    I missed the fact he only had a single equal sign when he first posted and thought it was a different issue when I posted the link.
Thread Status:
Not open for further replies.

Share This Page