ShopMadeSimple linking question

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
dikruo
Forum Members
Forum Members
Posts: 12
Joined: Sat Jan 24, 2009 10:12 am

ShopMadeSimple linking question

Post by dikruo »

First of all, Thanx to all the great developers of CMSMS!!!
I've set up a fairly nice website in just a few hours containing a webshop

HTTP://www.4yourdog.nl

I have a question though. In the productlist, only the "product name" links to the "product-detail-TAB."
I would like the product name, description and product image to link to the same product detail tab.

I've tried a million things inside the PHP script, but I can't seem to get things right.

Below the code which builds the link for "PRODNAME" but doesn't build it for "PRODDESC" and "IMG"

Thanx for any help in advance,

Matthijs

Code: Select all

$rowclass = 'row1';
$entryarray = array();

while ($dbresult && $row = $dbresult->FetchRow())
{
	$onerow = new stdClass();

	$onerow->prodid = $row['product_id'];
	$onerow->prodname = $this->CreateLink($id, 'fe_product_detail', $returnid, $row['prodname'], array('product_id'=>$row['product_id']));

	$onerow->proddesc = $row['proddesc'];
	// Prepare price, if no price state 'Sold out'
	if ($row['price'] != 0) {
		$onerow->price = $row['price'];
	}
	else {
		$onerow->price = $this->Lang('productsoldout');
	}
	// Build link to cart
	if ($cartMSInstalled) {
		$onerow->addproduct = $cmsmodules[$modulename]['object']->CreateLink( $id, 'cart', $returnid, $this->Lang('addtocart'), 
			array ('name'=>$row['name'],
				'perfaction' => 'add_product',
				'product_id' => $row['product_id'],
				'qty' => 1,
				'returnmod' => 'ShopMadeSimple'
			));
	}

	// Get the first picture available for the product found
	$query = "SELECT * FROM ".cms_db_prefix()."module_sms_product_images WHERE product_id = ?";
	$picture = $db->GetRow($query, array($row['product_id']));
	if ($picture)
	{
		if (isset($picture['image']) && $picture['image'] != 'no_image.jpg'&& $picture['image'] != '') {
			$onerow->prodimage = $pathproduct.$picture['image'];
		}
		else {
			$this->smarty->assign('prodimage', '*none');
		}
	}
	
	$onerow->rowclass = $rowclass;

	$entryarray[] = $onerow;

	($rowclass=="row1"?$rowclass="row2":$rowclass="row1");
}

$this->smarty->assign_by_ref('products', $entryarray);
$this->smarty->assign('lable_product_count', $this->Lang('textproductcount', count($entryarray)));
Duketown

Re: ShopMadeSimple linking question

Post by Duketown »

dikruo,

You might try something like:

Code: Select all

$onerow-> proddesc = $this->CreateLink($id, 'fe_product_detail', $returnid, $row['proddesc'], array('product_id'=>$row['product_id']));
You will notice that things don't work anymore (at least that was what I found out). This is because I wanted to make sure that there would only be a limited number of characters on one row. If the contains for example 2000 characters in total, all of them would be shown. To correct that I've build in templates\tab_categories.tpl on the description the following:

Code: Select all

<td class="productdesc">{$entry->proddesc|truncate}</td>
Due to the |truncate I have the idea that the CreateLink doesn't work anymore. I found the link on the length on the description more important then having the link working.
If you've found a solution, please let me know and I will build it in one of the next versions.

Regards,

Duketown
dikruo
Forum Members
Forum Members
Posts: 12
Joined: Sat Jan 24, 2009 10:12 am

Re: ShopMadeSimple linking question

Post by dikruo »

Duketown,

First of all thanx for your reply.

I have the first link working, from the "product-description" to the "product-detail-tab"

Like you said, I've removed the Truncate in the categories tpl.
When I did that, the image showed the productdescription as a sub-tekst below the picture, so I removed the {alt=$entry->proddesc} (as you can see by the two stars surrounding the text in the sourcecode below

Code: Select all

{foreach from=$products item=entry}
		<tr class="{$entry->rowclass}" onmouseover="this.className='{$entry->rowclass}hover';" onmouseout="this.className='{$entry->rowclass}';">
			
			<td><div class="productname">{$entry->prodname}</div></td>
			<td><div class="productdesc">{$entry->proddesc}</div></td>
			<td><div class="productprice">{$entry->price}</div></td>
			<td><div class="addproduct">{$entry->addproduct}</div></td>
			{if $prodimage!='*none'}<td class="img">
				{image src=$entry->prodimage {*alt=$entry->proddesc*}</td>
			{/if}
		</tr>
	{/foreach}
I've used the PHP-code you've given (basicly the same as for the productname link)

Code: Select all

$onerow-> proddesc = $this->CreateLink($id, 'fe_product_detail', $returnid, $row['proddesc'], array('product_id'=>$row['product_id']));
So that works.....

Now only the image link remains.

When I use

Code: Select all

$onerow->prodimage = $this->CreateLink($id, 'fe_product_detail', $returnid, $pathproduct.$picture['image'], array('product_id'=>$row['product_id']));
instead of the now used image code:

Code: Select all

$onerow->prodimage = $pathproduct.$picture['image'];
I don't see my image anymore, only this:

Code: Select all

/products/hondentrui1.jpg" alt="[/products/hondentrui1.jpg]" title="[/products/hondentrui1.jpg]"/>  
The text "[/products/hondentrui1.jpg]" works as a link, but no image is shown.

Any ideas?

Again Thanx in advance!

Regards
Matthijs
Milan J.
New Member
New Member
Posts: 7
Joined: Tue Jan 13, 2009 5:44 pm

Re: ShopMadeSimple linking question

Post by Milan J. »

I have the same problem, can't get an image linked to detail page. Has anyone found any solution to this problem?

Thanks a bunch.
Duketown

Re: ShopMadeSimple linking question

Post by Duketown »

dikruo,

Locate a HTML help page using a search engine. Make sure to locate the coding.
Use that to format the the createlink.

Duketown
Post Reply

Return to “Modules/Add-Ons”