0

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.

Pathfinder
  • 165
  • 1
  • 7
  • Maybe I'm thinking too simple now, but what about adding just another "job expiration" date field and not using the entry expiration date at all? You can simply use that in your _entry template to show/do something else when the job has expired. –  Sep 08 '15 at 13:35
  • Thanks Jeroen, creative thinking, thank you, it is definitely one way to go about it. However, in the dashboard this would remove the ability to filter expired jobs/entries and over time create pages and pages of entries we don't need to see. – Pathfinder Sep 08 '15 at 13:51
  • 1
    status(null) will give you all entries irregardless of status – Luke Holder Sep 08 '15 at 15:28
  • 1
    Hey Pathfinder, have a look at my answer to the related question! ^^ – carlcs Sep 08 '15 at 16:18
  • 1
    This question/answer does a great job of walking through a similar issue. She's tackling future entries, while you're tackling past entries, but other than that the solution is the same. – Lindsey D Sep 08 '15 at 17:18
  • Thanks for the comments, I'll have another look and see how I get on. – Pathfinder Sep 09 '15 at 09:43
  • @lindsey-d having fun getting this working, trying a new section as the jobs affects the live site etc. Fetching the segment okay for the slug, but the craft.entries is drawing a blank. – Pathfinder Sep 09 '15 at 13:20
  • @carlcs as above, I can see now what I was missing in your post. Lindsey's forwarded answer lays out the steps and helped flesh out the issue. Still having fun as described above. – Pathfinder Sep 09 '15 at 13:21
  • Okay, so I solved the issue of the redirect failing to fetch a record with the slug. – Pathfinder Sep 09 '15 at 13:29
  • @Pathfinder I would highly recommend to get rid of this jobs/{jobTitle|kebab}-{jobCity|kebab}-{jobId|kebab} and use jobs/{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:31
  • @Pathfinder This should also make your record fetching more straight forward. To automatically get your slugs look like that kebab party you have right now, I'd make use of the automatic entry titles feature. – carlcs Sep 09 '15 at 13:35
  • @carlcs funny you should mention that :)

    After 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
  • So I have got this all working now using:

    {% 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:11
  • @carlcs I think the main thing I didn't understand from your answer was that I had to use routing. That is my bad, but the fields you mentioned are the same as in the section fields, which is why I thought it wasn't working.

    My 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:13
  • @Pathfinder But as soon as they edit one of these fields, you get a new URI and with that you start fresh in allt hings google, confuse site visitors who bookmarked that job's site. The slugs field is there for a reason! Can't you just train your useres to not mess with the field (or use CPJS to hide it from them)? – carlcs Sep 09 '15 at 14:14
  • @carlcs That is true, but generally they don't edit these fields once setup - where as they are terrible at getting the slug right.

    I 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
  • Ahh nice, didn't even notice you have the ID in your generated URI. :) – carlcs Sep 09 '15 at 14:32

0 Answers0