Products Landing Page

Hello.



Does anyone know what I should do to create a custom landing page?



I have a selection of products in my store that I wish to add to a custom landing page. I'd like to have some introduction text, then some products, then some more text, then some more products, etc.



Seems like the logical choice would be to add a products listing widget, however that does not seem possible to do on store pages.

Hello denisgomes!



You can try to do the following:[list]

[]Please go to Website → Content and create a new page that will play a role of your custom landing page.

[
]Go to Design → Layouts and press the Add location. Choose the Dispatch - View page. Enter the Name, etc. Click the Pages tab and add your created page. Save.

[]Create the grid and add blocks to this location. First add the HTML block where you can input the necessary text, then below it Products block with the necessary products, then HTML block again, then Products block.

[
]Check the page url in the storefront, you will see how it looks like.

[/list]



Best regards, Alt-team

That worked like a charm, alt-team, thanks! Check it out: http://www.produtose…adesuporte.html



Now I have one more thing to do. Some of these products are customized and have an 'which image would you like to use' option. I have modified the store so that the image can be passed on via a URL parameter, like this:



http://www.produtose…Suporte_993.jpg



With that mod the image is shown right on the product details page. Also, the store throws an error if the user tries to buy the product without specifying the desired image.



What I need to do now is add that functionality to the landing page, so that the product links in there also pass the URLTIRINHA parameter if it's present when calling the landing page: http://www.produtose…ltirinha=



I was already thinking of ways to do that but seems that CS-Cart does not allow the use of PHP on pages. I've searched these forums for ways to enable PHP inside pages or something like that, but it seems impossible under 4.x, even inside Smarty which explicitly allows it via {php} tags. Any other ideas?

I found a file called grid_list.tpl which controls the product listing on the block I used on that page. Looks like I'll need to modify this file in order to do what I want, and I confirmed that by making a small change. However, I can not seem to find how or where the file adds the hyperlink to the product. Beginning on line 61:




{if $item_number == "Y"}{$cur_number}. {math equation="num + 1" num=$cur_number assign="cur_number"}{/if}
{assign var="name" value="name_$obj_id"}{$smarty.capture.$name nofilter}

{assign var="rating" value="rating_$obj_id"}
{$smarty.capture.$rating nofilter}





Shouldn't there be a somewhere in there?

[quote name='denisgomes' timestamp='1401472829' post='184693']

I found a file called grid_list.tpl which controls the product listing on the block I used on that page. Looks like I'll need to modify this file in order to do what I want, and I confirmed that by making a small change. However, I can not seem to find how or where the file adds the hyperlink to the product. Beginning on line 61:




{if $item_number == "Y"}{$cur_number}. {math equation="num + 1" num=$cur_number assign="cur_number"}{/if}
{assign var="name" value="name_$obj_id"}{$smarty.capture.$name nofilter}

{assign var="rating" value="rating_$obj_id"}
{$smarty.capture.$rating nofilter}





Shouldn't there be a somewhere in there?

[/quote]



You can find the following code in the “design/themes/basic/templates/common/product_data.tpl”:



{capture name="name_`$obj_id`"}
{if $show_name}
{if $hide_links}{else}
{/if}{$product.product nofilter}{if $hide_links}{else}{/if}
{elseif $show_trunc_name}
{if $hide_links}{else}{/if}{$product.product|truncate:45:"...":true nofilter}{if $hide_links}{else}{/if}
{/if}
{/capture}




Hope that helps.

That definitely helps, thanks! Now I need to figure out how to access URL parameters from within a template, or how to run PHP inside them.

Okay, I couldn't figure out how to run PHP inside Smarty, so I found something else, but it seems that it's not working either.



Can someone please confirm if {$smarty.get.} actually works? I really really need to get the URL parameters for that page.

Okay, just found an answer. It's {$smarty.request.} and not {$smarty.get.}. But it's still not working as expected. Seems like I'm having some caching issues.

[quote name='denisgomes' timestamp='1402371618' post='185443']

Okay, I couldn't figure out how to run PHP inside Smarty, so I found something else, but it seems that it's not working either.



Can someone please confirm if {$smarty.get.} actually works? I really really need to get the URL parameters for that page.

[/quote]



PHP code inside smarty is forbidden in CS-Cart.



Try to print the content of the request paramters using the following code:


{$smarty.request|fn_print_r}



to check if the issue is caused by the cache.

$smarty.request actually works and I managed to make it do what I want. However I still have some caching issues, ie, the first time I call up the page it uses the correct values for the parameter, but when I change it the page still displays the old values unless I wait a few minutes or clear the cache.



Is there a way to disable caching only for a specific page or a specific block?

[quote name='denisgomes' timestamp='1402400092' post='185469']

$smarty.request actually works and I managed to make it do what I want. However I still have some caching issues, ie, the first time I call up the page it uses the correct values for the parameter, but when I change it the page still displays the old values unless I wait a few minutes or clear the cache.



Is there a way to disable caching only for a specific page or a specific block?

[/quote]



There is an ability to disable cache for specific blocks via shemas. What block do you use?

I'm using the Product Listing block inside a static page.

If you use manually filling, open the “app/schemas/block_manager/blocks.php” file and replace this part of code:



'manually' => array (
'picker' => 'pickers/products/picker.tpl',
'picker_params' => array (
'type' => 'links',
),
),




with:



'manually' => array (
'picker' => 'pickers/products/picker.tpl',
'picker_params' => array (
'type' => 'links',
),
'disable_cache' => true,
),




Then clear the cache. Note that the cache will be disabled for all blocks with products and manually filling

Thanks for the tip, I'll try that later. In the meantime I have another question: that $smarty.request modification is now working for all links to products anywhere in the store (which is great). I noticed, however, that this caching issue does not manifest itself in product categories listings - I can change the URL parameters and it reflects correctly in the links.



I guess this could be interpreted as 'pages are cached, product listings are not'. Am I correct?

[quote name='denisgomes' timestamp='1402415143' post='185487']

Thanks for the tip, I'll try that later. In the meantime I have another question: that $smarty.request modification is now working for all links to products anywhere in the store (which is great). I noticed, however, that this caching issue does not manifest itself in product categories listings - I can change the URL parameters and it reflects correctly in the links.



I guess this could be interpreted as 'pages are cached, product listings are not'. Am I correct?

[/quote]



You can find the following string of code in the blocks.php file:



'request_handlers' => array ('current_category_id' => '%CATEGORY_ID%'),




It means that the cache of the blocks with products is cleared then there is the category_id parameter in the request URL. In other words, then you switch between categories blocks with products are not taken from cache.

Okay, tried adding the disable_cache directive but that didn't work. I noticed this directive is also present in the 'recent products' part of that file, so I don't understand why this won't work.

Maybe that cache directive is related to the list of products itself, and not their links?



Would it be possible to disable caching altogether for a single page, since this was built on a page? Would it be easier?

Had another idea… assign the custom layout to a category instead of a page. That works (BTW it's a nice way to change the layout of a store category, especially when doing promotions such as Christmas, Valentine's day, etc), but the links are still being cached, they do not update.

And here I am reopening this thread just to say that I finally managed to do exactly what I wanted to do.



Instead of trying to modify the product links on the store to add the URLTIRINHA parameter (which wouldn't work due to CS-Cart caching system), I came up with another idea: setting up cookies.



I created a small redirect file in PHP which would read the URLTIRINHA parameter, set a cookie and then redirect to the store. Afterwards I can read that cookie via Smarty, which is supported inside blocks, layouts, pages and products. I also modified the product options template to read that cookie and fill in the corresponding product option text box automagically.



If you want to see this live just go to www.vidadesuporte.com.br and click on any 'Buy this product…' link below any of the comic strips. But please do not place test orders. If you want more details on what I did, just post it here.

And here I am reopening this thread just to say that I finally managed to do exactly what I wanted to do.

Instead of trying to modify the product links on the store to add the URLTIRINHA parameter (which wouldn't work due to CS-Cart caching system), I came up with another idea: setting up cookies.

I created a small redirect file in PHP which would read the URLTIRINHA parameter, set a cookie and then redirect to the store. Afterwards I can read that cookie via Smarty, which is supported inside blocks, layouts, pages and products. I also modified the product options template to read that cookie and fill in the corresponding product option text box automagically.

If you want to see this live just go to www.vidadesuporte.com.br and click on any 'Buy this product...' link below any of the comic strips. But please do not place test orders. If you want more details on what I did, just post it here.

Hi Could you please post the code ?