Jump to content

Fetching 1 entry from database


madmega

Recommended Posts

Hi, we've installed this module, giftonshop, and it works great.

But now we want something different done to it.

This module shows group of gifts with a product, as a extra, with each brand, you can choose from 4 gifts.

But it is also possible to have another group of gifts, which shows up as another div block where you can choose 4 gifts.

Those gifts are other products...

 

What we want is to have 1 block, showing all 8 gifts.

The problem is, that the block extra_right.tpl is called with every group of gifts.

So all the arrays in that block are concentrated one ID in the database, say for instance that group1, that has 4 gifts, has a ID of 21.

Group 2 has 4 gifts and has a ID of 22.
So when extra_right.tpl is called from ID 21, i cannot get products from ID 22.
And i do not know how to call them, i can make if statements and foreach loops, but they all contain the products from ID 21.

Here is the code:

{if isset($giftonorder_gifts_of_product) AND count($giftonorder_gifts_of_product)}
{foreach from=$giftonorder_gifts_of_product item=gift}
	{if sizeof($gift.gift_products_list) > 0}
	<div class="giftonorder_productgifts">

	{if $gift.id_giftonorder == 21}
	<h2>Amplug & Amphones</h2>
	{else}
	<h2>{$gift.name}</h2>
	{/if}
	
	<div style="padding: 10px">
	<p><span class="choose_gift">{l s='Choose your gift:' mod='giftonordermodule'}</span>
		<select name="noname" class="giftonorder_preselector" >
					{foreach from=$gift.gift_products_list key=key_gift_prod item=gift_prod name=counter}
				<option {if $key_gift_prod==$gift.index_selected_gift}selected="SELECTED"{/if} value="{$gift.id_giftonorder}_{$gift_prod->id}" >{$gift_prod->legend|truncate:2000:'...'|escape:htmlall:'UTF-8'} </option>
			{/foreach}
			
			{if $gift.id_giftonorder == 21}


			
			{foreach from=$gift.gift_products_list item=gift_prod name=counter}
			<option {if $key_gift_prod==$gift.index_selected_gift}selected="SELECTED"{/if} value="{$gift.id_giftonorder}_{$gift_prod->id}" >{$gift_prod->legend|truncate:2000:'...'|escape:htmlall:'UTF-8'} </option>
			<option {if $key_gift_prod==$gift.index_selected_gift}selected="SELECTED"{/if} value="{22}_{39492}" >MARK </option>
			{/foreach}
			{/if}
		</select>
	</p>
	
	{foreach from=$gift.gift_products_list key=key_gift_prod item=gift_prod name=counter}
	<p style="text-align: center">
		<img class="goo_preselectinfo goo_preselectinfo_{$gift.id_giftonorder}_{$gift_prod->id} {if $key_gift_prod<>$gift.index_selected_gift}hidden{/if}" 
			src="{$link->getImageLink($gift_prod->link_rewrite, $gift_prod->id_image, 'large')}"  
		alt="{$gift_prod->legend}" height="{$largeSize.height}" width="{$largeSize.width}" />
	</p>
	<p style="text-align: center" class="goo_preselectinfo goo_preselectinfo_{$gift.id_giftonorder}_{$gift_prod->id} {if $key_gift_prod<>$gift.index_selected_gift}hidden{/if}" >{$gift_prod->legend}
		{if $gift_prod->price_without_reduction_wtx <> 0} 
			<span class="price strike">
			{if !$priceDisplay || $priceDisplay == 2}
				<span >{convertPrice price=$gift_prod->price_without_reduction_wtx}</span>
			{/if}
			{if $priceDisplay == 1}
				<span >{convertPrice price=$gift_prod->price_without_reduction_wotx}</span>
			{/if}
			</span>
		{/if}
	</p>
	<p style="text-align: center" class="goo_preselectinfo goo_preselectinfo_{$gift.id_giftonorder}_{$gift_prod->id} {if $key_gift_prod<>$gift.index_selected_gift}hidden{/if}" >
	{$gift_prod->description_short|strip_tags|truncate:170:'...'}
	</p>
	{/foreach}
	
	<p class='align_center'><a class="button" href="{$modules_dir}giftonordermodule/all_giftonorder.php">{l s='See Conditions' mod='giftonordermodule'}</a></p>
	</div>
	</div>
	{/if}
{/foreach}
{/if}



The piece of code:
            {if $gift.id_giftonorder == 21}


            
            {foreach from=$gift.gift_products_list item=gift_prod name=counter}
            <option {if $key_gift_prod==$gift.index_selected_gift}selected="SELECTED"{/if} value="{$gift.id_giftonorder}_{$gift_prod->id}" >{$gift_prod->legend|truncate:2000:'...'|escape:htmlall:'UTF-8'} </option>
            <option {if $key_gift_prod==$gift.index_selected_gift}selected="SELECTED"{/if} value="{22}_{39492}" >MARK </option>
            {/foreach}
            {/if}

 

Is the place where it should get all the entries from ID 22, but how do i do it ?

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...