Add message if no product added

Discussion in 'Templates customization' started by mdmr_llc, May 25, 2011.

  1. mdmr_llc

    mdmr_llc Member

    Joined:
    Aug 22, 2006
    Messages:
    62
    I have the following setup: User creates a basic account to login to member.php. From there they can add other products through Add/Renew Subscription drop-down. When a product is added, it will shown in a bulleted format list above.

    {foreach from=$member_products item=p}

    {if $p.url gt "" }
    <li><a href="{$p.url}">{$p.title}</a></li>
    {/if}

    {foreach from=$p.add_urls item=t key=url}
    <li><a href="{$url}">{$t}</a></li>
    {/foreach}
    {/foreach}

    How do I detect if no product is added yet in order to put a message there?:confused:
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Actually that code already was available in default template :
    Code:
    {if $smarty.session._amember_products}{* Customer have active subscriptions, display it if config allows *}
        <h3>#_TPL_MEMBER_SUBSCR#</h3>
        <ul>
        {foreach from=$member_products item=p}
        <li>
        {if $p.url gt "" }
            <a href="{$p.url}">{$p.title}</a>
        {else}
            <b>{$p.title}</b>
        {/if}
        </li>
        {foreach from=$p.add_urls item=t key=url}
            <li><a href="{$url}">{$t}</a></li>
        {/foreach}
        {/foreach}
        </ul>
    {else}{* Customer doesn't have any active subscriptions *}
        <h3>#_TPL_MEMBER_NO_SUBSCR#</h3>
        #_TPL_MEMBER_USE|<i>|</i>#<br />
        #_TPL_MEMBER_ORDER_SUBSCR#<br />
    {/if}
    
    

Share This Page