Forum

Thread tagged as: Problem, Addons, Add-on-development

Problem with template option in Shop App page functions

I came across a problem while attempting to pass in custom templates in the new Shop App (gamma 1).

Per the documentation, displaying a product like this works fine: perch_shop_product('my-product');

I know that the default template is shop/products/product.html. When I edit product.html my edits come through properly.

However...

If I try to display a product using these functions, I get no output at all:

perch_shop_product('my-product', [ 'template' => 'product.html' ]);

perch_shop_product('my-product', [ 'template' => 'my-template.html' ]);

Any time I use the template option, I get nothing. Other options, such as count work properly. I'm getting the same result using perch_shop_products(); where the default template is list.html. I've copied over the template files in the shop download to my templates folder as per usual...

Many thanks!


Time Δ Debug Message 0.0189 0 SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='5185b59ed90ba3360d076e3bcab1c5e0' LIMIT 1 0.0195 0.0006 UPDATE perch2_users SET userHash='d0f30f61b5e8cb44ad41c567475a13b3' WHERE userID='1' 0.0198 0.0003 SELECT p.privKey FROM perch2_user_privileges p 0.0216 0.0019 SELECT * FROM (SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=1 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID 0.0581 0.0365 SELECT * FROM perch2_shop_products WHERE productID='1' LIMIT 1 0.0668 0.0087 Using template: /templates/shop/products/product.html 0.084 0.0172 SELECT productID, productVariantDesc, stock_level FROM perch2_shop_products WHERE parentID=1 AND productDeleted IS NULL ORDER BY productOrder ASC 0.0986 0.0147 SELECT * FROM perch2_shop_brands ORDER BY brandTitle ASC 0.1008 0.0022 SELECT * FROM perch2_categories c, perch2_category_sets s WHERE c.setID=s.setID AND s.setSlug='products' ORDER BY catTreePosition ASC 0.1043 0.0035 SELECT * FROM perch2_shop_currencies WHERE currencyActive=1 ORDER BY currencyID=142 DESC, currencyCode 0.1058 0.0016 SELECT * FROM perch2_shop_currencies WHERE currencyActive=1 ORDER BY currencyID=142 DESC, currencyCode 0.1072 0.0014 SELECT * FROM perch2_shop_currencies WHERE currencyActive=1 ORDER BY currencyID=142 DESC, currencyCode 0.1086 0.0014 SELECT * FROM perch2_shop_tax_groups ORDER BY groupTitle ASC 0.114 0.0054 Queries: 13 0.1141 0.0001 Memory: 4.2141
Olympia Kyriakides

Olympia Kyriakides 1 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

That should be how it works, but how about if you do this:

perch_shop_product('my-product', [ 'template' => 'shop/my-template.html' ]);

Still nothing, even with the entire file path.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is your template in the shop/products folder alongside product.html? If so the path should be:

perch_shop_product('my-product', [ 'template' => 'products/my-template.html' ]);

That's where my template is, still I get nothing when specifying a template.

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you turn on debug, what does it output?

Add this to your config file:

define('PERCH_DEBUG', true);

Drew, I think it was an issue of the file path and "products" folder after all. This works now:

perch_shop_product('my-product', [ 'template' => 'products/my-template.html' ]);

Thanks for looking at it with me!

Drew McLellan

Drew McLellan 2638 points
Perch Support

Great! :)