I'm trying to find the best way to let expired entries display.
My client has jobs that are filled / expire.
A typical job url looks like this:
https://flourish-uk.com/jobs/sous-chef-maidstone-20881
In the section settings I've got:
Entry URL format set to:
jobs/{jobTitle|kebab}-{jobCity|kebab}-{jobId|kebab}
And the entry template set to:
jobs/_entry
Everything works great. When a job expires/entry expires it no longer appears, but of course the google index remains and so I'd like the page to still 'exist' rather than redirect to a 404.
I've done a bit of work with the 404 so that the /jobs/ part is recognised in the URL and I change the content, as well as fetch expired job data, such as the jobTitle and integrate it into the content. The problem is, Google still sees a 404 page, and the content of the page is different which will invariably create some negative page rank issues given the number of expired jobs that are accruing.
So rather than a 404, I'd like the expired:
/jobs/sous-chef-maidstone-20881
Entry to go to the _entry template and show the original unexpired layout (albeit with some tweaks to explain the job has expired).
But despite following the details found here:
Is it possible to view 'Expired' entrys on the front end?
The _entry still redirects to the 404 page when an entry is expired.
Is there any way to stop this so I can perform some .status('expired') voodoo on it?
Many thanks.
jobs/{jobTitle|kebab}-{jobCity|kebab}-{jobId|kebab}and usejobs/{slug}instead. I didn't notice this when posting yesterday, but you should really use the slug for your urls. – carlcs Sep 09 '15 at 13:31After much head scratching (The slug wasn't fetching any records), I realised that the slug was different from the URI.
The problem I have with slugs for the jobs is two fold - first and foremost - the users can edit it - and they do mess it up (Which is why my randomly picked job entry was failing - they'd messed with the slug!
The auto generated titles are far more reliable and consistent, taking fields they've filled in elsewhere to form the generated title, and thus, the URI.
– Pathfinder Sep 09 '15 at 14:06{% set uri = craft.request.getSegment(2) %} {% set jobs = craft.entries.section("jobs").uri('jobs/' ~ uri).status('live', 'expired').find() %}
This has the advantage of not having to change the listing record manually in the listing template, instead just using the auto-generated uri which is reliably created. In the answer mentioned by Lindsey it says turn off the entries have unique URL's, which I've ignored - I want the auto-generated URL's :)
– Pathfinder Sep 09 '15 at 14:11My routing is using /jobs/* and all is good.
I'd like to thank you both for the feedback - solved a big issue for me and your time and talent is truly appreciated!
– Pathfinder Sep 09 '15 at 14:13I have got a catch in the 404 that looks for /jobs/ in the first segment. What I then do is do a 301 redirect to a page that strips out just the jobId number and pulls the job entry in.
{% redirect '/jobs/position-filled?jobId=' ~ craft.request.url|split('-')|last 301 %}
Ideally I'd also use the jobId instead of the uri to pull the job entries, but they aren't always reliable with the jobId either - sometimes using the same number twice!
– Pathfinder Sep 09 '15 at 14:21