Portfolio with Categories - link to category not working
I have followed the step-by-step tutorial for this but when I create a link to the category it does not work. When I click on the category it seems to find a page but nothing displays not even the global header and footer.
I'm thinking this is something to do with the path I have in this section but there is no explanation as to what this path should be if I have my files in a folder and am not using htaccess to avoid displaying .php on my pages.
<perch:categories id="Work" label="Type of work" set="type" required="true">
<perch:before>
<h3>Tags</h3>
<ul class="tags">
</perch:before>
<li><a href="/work/category.php/<perch:category id="catPath" />"><perch:category id="catTitle" /></a></li>
<perch:after>
</ul>
</perch:after>
</perch:categories>
from the root my category.php is in work/category.php as are listing and detail pages for this portfolio. I have tried a few different paths but nothing seems to work so I'm hoping you can help?
Link to the page: https://kc.kubiaktest.co.uk/work/detail.php?s=portwall-place
Hi Emily
Your link path structure is wrong and needs to instead be:
Then you also need to ensure that you have an appropriate rewrite rule in your .htaccess file.
At the moment this site is a test and hosted on a subdomain so I have no idea what the rewrite rule should be. Could you advise?
It shouldn't matter where it is hosted as you can have an .htaccess file in the root of the folder for this test site.
The actual rule would then be:
If you need the full .htaccess rewrite set up let me know.
Ok, I have gone back over the video and used that code you have given me as the rewrite. I've also actioned it for the detail.php file as suggested in the video. The rewrite works for the listing link to the detail pages but it's still not working for the categories.
I'm still just getting a blank page, could it be something I'm missing in the code on the category.php page?
It could be but I am not part of the Perch team, just advising you on what I know from using it :) Can you check the PHP error logs on your server? Can you post your code here?
I'm not getting a 404 error or anything I'm just getting a blank page. It has the correct background tint so it is registering the css.
The only errors I have that point to these pages look just like this:
my htaccess says this:
I'm using this php to call the categories in:
Does that help?
You wouldn't get a 404 unless the page hadn't been found so it looks like a page is at least being loaded (though maybe not the right one).
The easiest way to check the page itself is working is to bypass the nice url for the moment, so try putting in the full url manually into the browser and see what happens, for example
https://kc.kubiaktest.co.uk/work/category.php?cat={put a category slug here]
Ok, I think is must be something to do with the page because it's still blank when I use the full url.
It seems to be the php, if I take the above (my last reply) perch_category code block out of the page it displays all of the other content i.e. header and footer but when I pop it back in it's a blank page again with no content at all.
Does that give any indication of what's wrong?
I have copied and pasted that code from the tutorial and not changed the rest of my page at all, I have also tried the code below and it does the same.
All my other pages work fine.
Sorry! I've just found this in my error log:
What's on line 7 is
or
depending on what bit of those two examples I've paste in but seems like both of them bring in that error.
I did have to update my version of perch to get categories to do this part of the site. Could I have missed something while updating?
I don't think so but not 100% sure - that is something Drew or Rachel would have to answer
I presume you have your html templates set up correctly as per the tutorial?
I believe so, I'll go back through the tutorial and make sure I've done everything...
I cannot find the problem. Could Drew or Rachel weigh in on this feed?
What's the current problem?
The problem is that I have followed the instructions in the Portfolio with Categories video tutorial but when I get to the point where I paste this code:
into my category.php file and test it, it brings back a blank page, no header or footer but the background colour.
I cannot for the life of me figure out what the problem is because I've gone over the tutorial several times and all seems to work up until that point so I'm hoping you can help?
Have you added the Categories app in your
config/apps.php
file?Ooops!! No you are right I haven't. red face Is that a case of putting 'perch_categories', in that file?
Oh no wait it's just 'categories', isn't it?
Yes, see https://docs.grabaperch.com/docs/installing-perch/installing-apps/
It's either like this for new configurations:
or like this for legacy sites:
Thank you Drew!!!