PDA

View Full Version : Why dont this button work ?



Peter Jonsson
August 5, 2012, 03:09 PM
Im working on 'listing_details.tpl' trying to make a button if they use a field with link.

The code that i thought would work are:

{if $item.Key == 'produkt_lank'}<a class="button" href="{$item.value}">Produkten</a>{/if}

Im thinking like this that if that item key are used it will be using the button class.
But it just looks wierd and not where the actual item key are placed on the site.

Will this not work or am i doing something wrong ?

Vladimir
August 6, 2012, 04:09 AM
It should works is properly. But you need as add the field "produkt_lank" to listing form in admin panel.



{if $item.Key == 'produkt_lank'}<a class="button" href="{$item.value}">Produkten</a>{else}{$item.value}{/if}

Peter Jonsson
August 6, 2012, 06:21 AM
I have a listing field "produkt_lank" where they fill in the direkt link to their product that they want to sell to make it easier for visitors to go and buy it.

I place the code in "listing_details.tpl" but it doesnt work as it should.

I have made it so it make a button but it uses the link as a name making the button long because it takes all the text and not only the link from the value.

It only makes a new line and not taking the existing field value and make that into a button.

Here you can see how it look:
http://img407.imageshack.us/img407/1947/buttonerror.png (http://imageshack.us/photo/my-images/407/buttonerror.png/)


How it looks when i view the site in html mode.


<table class="table">
<tr id="df_field_produkt_lank" >
<td class="name">Produkt lank:</td>
<td class="value" <li style="padding: 20px 0 0 0;"><a class="button" href="<a target="_blank" class="static" href="http://www.rygarden.se/produkt/Covert-Special-Ops-Code-black-ir">www.rygarden.se/produkt...vert-Special-Ops-Code-black-ir</a>">Produkten</a></li>>
<a target="_blank" class="static" href="http://www.rygarden.se/produkt/Covert-Special-Ops-Code-black-ir">www.rygarden.se/produkt...vert-Special-Ops-Code-black-ir</a>
</td>
</tr>
</table>



Here you see the code and where i have put it.


<!-- listing info -->
{rlHook name='listingDetailsPreFields'}

{foreach from=$listing item='group'}
{if $group.Group_ID}
{assign var='hide' value=true}
{if $group.Fields && $group.Display}
{assign var='hide' value=false}
{/if}

{assign var='value_counter' value='0'}
{foreach from=$group.Fields item='group_values' name='groupsF'}
{if $group_values.value == '' || !$group_values.Details_page}
{assign var='value_counter' value=$value_counter+1}
{/if}
{/foreach}

{if !empty($group.Fields) && ($smarty.foreach.groupsF.total != $value_counter)}
{include file='blocks'|cat:$smarty.const.RL_DS|cat:'fieldse t_header.tpl' id=$group.ID name=$group.name}

<table class="table">

{foreach from=$group.Fields item='item' key='field' name='fListings'}
{if !empty($item.value) && $item.Details_page}

<tr id="df_field_{$item.Key}" {if $item.Key=='ad_title'}class="hide"{/if} {if $item.Key=='ad_description'}class="hide"{/if}>
<td class="name">{$item.name}:</td>
<td class="value {if $smarty.foreach.fListings.first}first{/if}">
{if $item.Opt1}
{if $item.Opt2}
{assign var='col_num' value=$item.Opt2}
{else}
{assign var='col_num' value=3}
{/if}
<table class="checkboxes{if $col_num > 2} fixed{/if}">
<tr>
{foreach from=$item.Values item='tile' name='checkboxF'}
<td><div title="{$lang[$tile.pName]}" class="{if $tile.ID|in_array:$item.source}checkbox_active{els e}checkbox{/if}">{$lang[$tile.pName]}</div></td>
{if $smarty.foreach.checkboxF.iteration%$col_num == 0 && !$smarty.foreach.checkboxF.last}
</tr>
<tr>
{/if}
{/foreach}
</tr>
</table>
{else}
{$item.value}
{/if}
</td>
</tr>
{/if}
{/foreach}
</table>

<!-- Start - Annons Information -->

<table class="table">

{foreach from=$group.Fields item='item' key='field' name='fListings'}
{if !empty($item.value) && $item.Details_page}

<tr id="df_field_{$item.Key}" {if $item.Key=='ad_title'}class="hide"{/if}
{if $item.Key=='b_address'}class="hide"{/if}
{if $item.Key=='fordon_bransle'}class="hide"{/if}
{if $item.Key=='fordon_bransle'}class="hide"{/if}
{if $item.Key=='drivhjul'}class="hide"{/if}
{if $item.Key=='field_kontakt_epost'}class="hide"{/if}
{if $item.Key=='fabrikat'}class="hide"{/if}
{if $item.Key=='efterlysning_forsvann'}class="hide"{/if}
{if $item.Key=='kaliber'}class="hide"{/if}
{if $item.Key=='Category_ID'}class="hide"{/if}
{if $item.Key=='jakthund_kon'}class="hide"{/if}
{if $item.Key=='kopes_sokes_pulldown'}class="hide"{/if}
{if $item.Key=='ny_county_lan'}class="hide"{/if}
{if $item.Key=='b_country'}class="hide"{/if}
{if $item.Key=='jaktvapen_licens'}class="hide"{/if}
{if $item.Key=='marke'}class="hide"{/if}
{if $item.Key=='fordon_miltal'}class="hide"{/if}
{if $item.Key=='modell'}class="hide"{/if}
{if $item.Key=='fordon_modellar'}class="hide"{/if}
{if $item.Key=='city'}class="hide"{/if}
{if $item.Key=='efterlysning_ort'}class="hide"{/if}
{if $item.Key=='annons_postnummer'}class="hide"{/if}
{if $item.Key=='price'}class="hide"{/if}
{if $item.Key=='produkt_lank'}class="hide"{/if}
{if $item.Key=='time_frame'}class="hide"{/if}
{if $item.Key=='ad_title'}class="hide"{/if}
{if $item.Key=='keyword_search'}class="hide"{/if}
{if $item.Key=='jakthund_stamtavla'}class="hide"{/if}
{if $item.Key=='b_states'}class="hide"{/if}
{if $item.Key=='field_kontakt_telefon'}class="hide"{/if}
{if $item.Key=='title'}class="hide"{/if}
{if $item.Key=='jakthund_uppfodare'}class="hide"{/if}
{if $item.Key=='posted_by'}class="hide"{/if}
{if $item.Key=='fordon_vaxellada'}class="hide"{/if}
{if $item.Key=='annons_vilkor'}class="hide"{/if}
>
<td class="value {if $smarty.foreach.fListings.first}first{/if}">
{if $item.Opt1}
{if $item.Opt2}
{assign var='col_num' value=$item.Opt2}
{else}
{assign var='col_num' value=3}
{/if}
<table class="checkboxes{if $col_num > 2} fixed{/if}">
<tr>
{foreach from=$item.Values item='tile' name='checkboxF'}
<td><div title="{$lang[$tile.pName]}" class="{if $tile.ID|in_array:$item.source}checkbox_active{els e}checkbox{/if}">{$lang[$tile.pName]}</div></td>
{if $smarty.foreach.checkboxF.iteration%$col_num == 0 && !$smarty.foreach.checkboxF.last}
</tr>
<tr>
{/if}
{/foreach}
</tr>
</table>
{else}
{$item.value}
{/if}
</td>
</tr>
{/if}
{/foreach}
</table>

<!-- Slut - Annons Information -->


{include file='blocks'|cat:$smarty.const.RL_DS|cat:'fieldse t_footer.tpl'}
{/if}
{else}
{if $group.Fields}
<table class="table">
{foreach from=$group.Fields item='item' }
{if !empty($item.value) && $item.Details_page}
<tr id="df_field_{$item.Key}" {if $item.Key=='ad_title'}class="hide"{/if}>
<td class="name">{$item.name}:</td>
<td class="value" {if $item.Key == 'produkt_lank'}<a class="button" href="{$item.value}">Produkten</a>{else}{$item.value}{/if}>
{if $item.Opt1}
{if $item.Opt2}
{assign var='col_num' value=$item.Opt2}
{else}
{assign var='col_num' value=3}
{/if}
<table class="checkboxes{if $col_num > 2} fixed{/if}">
<tr>
{foreach from=$item.Values item='tile' name='checkboxF'}
<td><div title="{$lang[$tile.pName]}" class="{if $tile.ID|in_array:$item.source}checkbox_active{els e}checkbox{/if}">{$lang[$tile.pName]}</div></td>
{if $smarty.foreach.checkboxF.iteration%$col_num == 0 && !$smarty.foreach.checkboxF.last}
</tr>
<tr>
{/if}
{/foreach}
</tr>
</table>
{else}
{$item.value}
{/if}
</td>
</tr>
{/if}
{/foreach}
</table>
{/if}
{/if}
{/foreach}
<!-- listing info end -->


I guess the best thing should be to make the existing URL into a button but i dont know where to change that.
I have looked some in the admins tpl but it's hard to find.

Vladimir
August 6, 2012, 09:31 AM
I've notice a small errors in your code, please see our code:



<!-- listing info -->
.........................

{foreach from=$listing item='group'}
{if $group.Group_ID }

.......................

{if !empty($group.Fields) && ($smarty.foreach.groupsF.total != $value_counter)}
{include file='blocks'|cat:$smarty.const.RL_DS|cat:'fieldse t_header.tpl' id=$group.ID name=$group.name}

<table class="table">
{foreach from=$group.Fields item='item' key='field' name='fListings'}
{if !empty($item.value) && $item.Details_page && !$item.hide_tab}
<tr id="df_field_{$item.Key}">
<td class="name">{$item.name}:</td>
<td class="value {if $smarty.foreach.fListings.first}first{/if}">
{if $item.Opt1}
{if $item.Opt2}
{assign var='col_num' value=$item.Opt2}
{else}
{assign var='col_num' value=3}
{/if}
<table class="checkboxes{if $col_num > 2} fixed{/if}">
<tr>
{foreach from=$item.Values item='tile' name='checkboxF'}
<td><div title="{$lang[$tile.pName]}" class="{if $tile.ID|in_array:$item.source}checkbox_active{els e}checkbox{/if}">{$lang[$tile.pName]}</div></td>
{if $smarty.foreach.checkboxF.iteration%$col_num == 0 && !$smarty.foreach.checkboxF.last}
</tr>
<tr>
{/if}
{/foreach}
</tr>
</table>
{else}
{if $item.Key == 'produkt_lank'}<a class="button" href="{$item.value}">Produkten</a>{else}{$item.value}{/if}
{/if}
</td>
</tr>
{/if}
{/foreach}
</table>

{include file='blocks'|cat:$smarty.const.RL_DS|cat:'fieldse t_footer.tpl'}
{/if}
{else}
{if $group.Fields}
<table class="table">
{foreach from=$group.Fields item='item' }
{if !empty($item.value) && $item.Details_page && !$item.hide_tab}
<tr id="df_field_{$item.Key}">
<td class="name">{$item.name}:</td>
<td class="value">
{if $item.Opt1}
{if $item.Opt2}
{assign var='col_num' value=$item.Opt2}
{else}
{assign var='col_num' value=3}
{/if}
<table class="checkboxes{if $col_num > 2} fixed{/if}">
<tr>
{foreach from=$item.Values item='tile' name='checkboxF'}
<td><div title="{$lang[$tile.pName]}" class="{if $tile.ID|in_array:$item.source}checkbox_active{els e}checkbox{/if}">{$lang[$tile.pName]}</div></td>
{if $smarty.foreach.checkboxF.iteration%$col_num == 0 && !$smarty.foreach.checkboxF.last}
</tr>
<tr>
{/if}
{/foreach}
</tr>
</table>
{else}
{if $item.Key == 'produkt_lank'}<a class="button" href="{$item.value}">Produkten</a>{else}{$item.value}{/if}
{/if}
</td>
</tr>
{/if}
{/foreach}
</table>
{/if}
{/if}
{/foreach}
<!-- listing info end -->


127

I hope it help you to resolve your problem.

Peter Jonsson
August 6, 2012, 10:49 AM
Whats the errors ? When i copied your code above into my i didnt see anything.

I get the button but the link is messed up. It doesnt only show the link he provided it shows all the code.

It should look like this:

<a target="_blank" class="static" href="http://www.rygarden.se/produkt/Covert-Special-Ops-Code-black-ir">www.rygarden.se/produkt...vert-Special-Ops-Code-black-ir</a>

But instead it look like this

<a class="button" href="<a target="_blank" class="static" href="http://www.rygarden.se/produkt/Covert-Special-Ops-Code-black-ir">www.rygarden.se/produkt...vert-Special-Ops-Code-black-ir</a>">Produkten</a>

How can i fix that ?

Vladimir
August 6, 2012, 11:55 AM
I've fixed it on your domain.

128

Peter Jonsson
August 7, 2012, 06:14 AM
Awsome! Thanks Vladimir!