Forum

Thread tagged as: Question, Blog, Shop

Perch File Organisation

Hello,

I've downloaded perch, the blog and the shop and have successfully installed it into a sub folder on my server. I've set up a test blog post, a test product and i've amedned the slugs in the settings

I've noticed that when clicking on a test product or a test blog post, it redirects to a folder (fro example /blog/ and /shop/) and then attempts to find the listing or product. I'm a little confused as to why, because when installing perch it doesn't contain either folder when unpacked.

So my question is how am i supposed to orgainse my files? Am i supposed to created these folders (i would like to have a blog folder and a shop folder to keep files well organised) and then add the necessary files in there?

What would you recommend?

Nathaniel Nwosu

Nathaniel Nwosu 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

It's completely up to you how to structure your site - what you're seeing there is just a default because it has to default to something.

I'd recommend deciding how you want your site to ideally be structured, and then updating the Perch configuration to fit that.

Hi Drew,

Thank you for that - after i sent that message i decided i would definitely like to have a blog folder and a shop folder and have began moving the relevant files to that folder. However i'm still coming up with 404s when i click on a product.

https://nathanieltest.co.uk/perch-dev/shop/products/test-product-01-testsku001/

Any ideas?


Edit:

Sorry I just noticed the previous comment didn't provide ny insight into why it possibly might be the problem. I have copied the products folder from /perch/addons/apps/perch_shop/templates/shop into /shop/products and i've still receiving an error. I would've thought moving the files should resolve it?

Drew McLellan

Drew McLellan 2638 points
Perch Support

It looks like you're getting an HTTP 500 rather than a 404. Have you checked your error log?

Ahh! You're right, not sure how i overlooked that!

Here's what it's dsiplaying:

[21-May-2016 14:25:49 UTC] PHP Warning:  include(/home/nathani5/public_html/perch-dev/perch/addons/apps/perch_blog/runtime.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/nathani5/public_html/perch-dev/perch/core/inc/apps.php on line 21
Drew McLellan

Drew McLellan 2638 points
Perch Support

It looks like you're missing a file. How are you deploying?

I'm not entirely sure what you mean by "deploying" in this sense so i'll list a couple details below that might help:

  • i'm editing the files locally and uploading it to my server
  • I'm on a cloud hosting platform at Tso Host
  • I was recently on cPanel Hosting however i had to upgrade to have the right php version to rin perch shop (could my transfer have been the problem?)
Drew McLellan

Drew McLellan 2638 points
Perch Support

How do you upload? Have you tried re-uploading?

FTP and i reploaded my core folder and still nothing. do you recommend a fresh install?

Right, so i uninstalled perch and all the apps. Deleted my database and user. Did a fresh download of perch, new database and user. Successful install of perch and all the apps, set up the shop, added some test products which successfully display on the page but when i click on the product link it goes to this url:

https://nathanieltest.co.uk/perch-dev/shop/products/test-product-01-test001/

which flags another error 500. now from my knowledge of the way perch works, within /shop/products/ there’s supposed to be a php template present where the information feeds into and is displayed to the user. However, by default, i don’t even have a shop folder! And as i said earlier, i’m happy to organise my files like /shop/products but this still doesn’t change the fact i appear to be missing a template file.

I’m out of ideas at the min, any help will be appreciated

Rachel Andrew

Rachel Andrew 394 points
Perch Support

You need to create any files needed to display your products. If you haven't created a file then there won't be a file there. We don't do this for you.

Have you created a page to list your products, eg https://docs.grabaperch.com/addons/shop/products/functions/perch-shop-products/

The actual structure of your shop is completely down to you.

Hi Rachel,

Thank you for your response, however i'm still not sure i understand. I've created this page - https://nathanieltest.co.uk/perch-dev/ which lists my test products and works perfectly. However when clicking a product i get an error, based on your response, i added an index.php page within

https://nathanieltest.co.uk/perch-dev/shop/products/

and added this snippet:

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

to display my product information which is still coming up with an error.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you literally have 'my-product' hard coded?

Yeah, i have a page called my-product.php with this snippet inside:

<?php
    perch_shop_product('my-product');
?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you have a product with the slug my-product? Normally you'd make that a dynamic value from the URL.

Hi Drew,

Thank you for your message, i think that's my problem. I didn't actually know that area was supposed to be dynamic. I've had a look through the documentation and can't see a snippet for that. But i looked at one of my other templates and used:

<?php
    perch_shop_product('<perch:shop id="slug" type="slug" />');
?>

but that also doesn't work

Drew McLellan

Drew McLellan 2638 points
Perch Support

If the slug was on the URL, e.g.

?product=my-product

you'd use

perch_shop_product(perch_get('product'));

So I still haven't been able to solve this and I'm not sure what I'm doing wrong.. I've tried

<?php
    perch_shop_product(perch_get('test-product-02-test002'));
?>

as my url is https://nathanieltest.co.uk/perch-dev/shop/products/test-product-02-test002/

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show be the route pattern or rewrite rule you're using to match that URL?

Hello,

The route pattern I have in the settings area of perch is /perch-dev/shop/products/{slug} and at the moment i'm not using a rewrite rule

Drew McLellan

Drew McLellan 2638 points
Perch Support

Update your route to give you slug segment a name:

perch-dev/shop/products/{slug:productslug}

and then use:

perch_shop_product(perch_get('productslug'));