V4.2.x Select "Featured" in usermodifylisting.tpl

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

  1. freeze2 Customer

    While working on an inventory based system for 68C, I noticed that while inputting a new listing, you can select if you want the listing "Featured". I have discovered though, that in the usermodifylisting.tpl, there is no code for changing the listing to "Featured" or "Not Featured". I did try inserting the following:

    Code:
    <label for="featured">Feature this listing on home page:</label>
    <select name="featured" id="featured">
    <option value="N">No Thanks</option>
    <option value="Y"{if $featured=="Y"} SELECTED{/if}>Yes Please</option>
    </select>
    
    The above code shows the label and options on the page but has no effect on the listing no matter which option is selected, have I possibly missed something?

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

    That is because modifying an existing add is modifying what has already been purchased. As many charge for an upgraded feature at the time of placement such as "featured", "Highlighted" or "Bold", allowing someone to modify that would be a "backdoor" to get the upgrade for free.

    To get to the modify listing, you click on the modify link from the userbrowselistings page. If you wanted to upgrade the listing (adding an upgrade feature), then you would click on the "upgrade" link instead of the modify link.

    The reason simply adding the form element on the user modify page has no affect is because the usermodifylisting.php file has no routine built in to upgrade the listing.

    When the upgrade link is chosen it goes to the renew.php file.
  3. freeze2 Customer

    Thanks Mike for this explanation...very helpful.
  4. freeze2 Customer

    Going the route of the renew process for featuring a listing, I found that the following did not seem to work:

    Approx line 175 of renew/step1.tpl

    Code:
    <option value="Y"{if $featured=="Y"} SELECTED{/if}>{$smarty.const.LANG_YES} (+{$cFeaturedPrice|format_money})</option>

    The if statement {if $featured=="Y"} SELECTED{/if} does not seem to work whether the listing is featured or not, I have checked both the default template as well as the custom template I am working on. To me, I would think it should read the following way: {if $featured=="Y"}selected="selected"{/if}, though this did not work either

    Is this possibly a bug?
  5. Mike-N-Tosh Developer & Moderator

    I know that you've been around a while and have been told how to find out what variables are in a given template by placing the smarty {debug} in your layout template file.

    This is NOT a bug. There is no variable $featured. The default template that you are referring to "renew/step1.tpl" already has this select/option in it starting around line number 160. Of course it is using the correct assigned variable for this upgrade option which is $cFeatured. It also has the other upgrade options as well right after it.

    Please look at the default template file that you said you also tested to see how it is already being done there. I am confused as to what you are trying to do, because this is already built into the template as it is. Have you modified other core php files? It is difficult to offer any real help without any further information other than a little snippet of file that already has the functionality that you are stating that you want to add.
  6. freeze2 Customer

    Thanks for the reply Mike,

    I switched over to the default template for testing.

    When logged in and on renew/step1.tpl, I was expecting that if the listing was already featured, the "Y" option in the drop-down menu should default to "Y" as selected:

    Is the if statement {if $featured=="Y"} SELECTED{/if} not supposed to change the order of the selected value to the code below if the listing is featured?

    Code:
    <select name="featured" id="featured">
        <option value="Y" >Yes</option>
         <option value="N">No</option>
    </select>
    If $featured is not an assigned variable and doesn't work in this template, why is it being used in the default template?

    No matter if the listing is featured or not, the order of the drop-down is:

    Code:
    <select name="featured" id="featured">
        <option value="N">No</option>
        <option value="Y" >Yes</option>
    </select>
    Maybe I'm missing something here...
  7. Mike-N-Tosh Developer & Moderator

    Please REREAD my last post. You are using the wrong variable.
  8. freeze2 Customer

    Thanks Mike...yes, I did REREAD

    My question was as posted:

    If $featured is not an assigned variable and doesn't work in this template, why is it being used in the default template?
  9. Mike-N-Tosh Developer & Moderator

    I'm not trying to be difficult, but as I said in my previous post. It isn't being used. There is no $featured variable.
  10. freeze2 Customer

    Here is the exact code pulled from the default template:

    Code:
    {if $cFeatured=="Y"}
    			<tr>
    				<td><label for="featured">{$smarty.const.LANG_ADD_FEATURED}{$smarty.const.LANG_COLON}</label></td>
    				<td>
    					<select name="featured" id="featured">
    					     <option value="N">{$smarty.const.LANG_NO_THANKS}</option>
    					     <option value="Y"{if [COLOR="Red"][B]$featured[/B][/COLOR]=="Y"} SELECTED{/if}>{$smarty.const.LANG_YES} (+{$cFeaturedPrice|format_money})</option>
    					</select>
    				</td>
    			</tr>
    			{/if}
    
    I've highlighted in red where it is being used in the default template.

    Now, I understand that the $featured variable does not work in this template, though it is in the code of the default template, which it probably shouldn't be as it does not work.

    The $cFeatured variable seems to only be for " if the "Featured" option is available in the package" ...so this also does not work for the order of the drop-down menu.

    Thanks!
  11. Mike-N-Tosh Developer & Moderator

    You know what? You are right. My most sincere apologies.

    This is a BUG! In the step1.php there is no query (unlike the admin) that actually gets any of the information from the listing itself. It only gets the order info and user info along with settings, etc.

    There should be a query that gets the Upgrade options from the actual listings table and assigns them to the template.

    Right before the last line:
    Code:
    $class_tpl->assign('body', 'renew/step1.tpl');
    It should have a routine something like this:
    Code:
    $lid = $_REQUEST['listingid'];
    $Listings->getListingById($lid);
    
  12. freeze2 Customer

    Perfect...we're traveling on the same road now

    Should I post this in the Bug Tracker ?
  13. Mike-N-Tosh Developer & Moderator

    YES, you should.
  14. Mike-N-Tosh Developer & Moderator

    I tested a fix and this does indeed correct this bug:

    In the includes/core/renew/step1.php file, add this right before the last line:
    Code:
    $listings = $Listings->getListingById(($_REQUEST['listingid']), 'modify');
    Again, this goes right before the last "code" line that is:
    Code:
    $class_tpl->assign('body', 'renew/step1.tpl');
    1 people like this.
  15. seymourjames All Hands On Deck

    This solves it
  16. freeze2 Customer

    Yup, good over here too...thanks for the fix.

    I also changed the template if statement to show the following:

    Code:
    {if $featured=="Y"}selected="selected"{/if}
  17. John Snyder Staff

Share This Page