1

I currently have a routing set up as follows to enable an "Edit" entry page following on from this question but I'm getting the following error message when going to that page.

Variable "entrySlug" does not exist

I have my routing set up as follows within my CP, which loads a URL like so mydomain.com/marketplace/authorname/entryname/edit

enter image description here

and within my listings/_edit

{# Find the entry by slug and author: #}
{% set listing = craft.entries({
    section: 'networks',
    slug: entrySlug,
    author: currentUser
}).one() %}

I'm really unsure why it can't find the slug of the entry.

3

If I'm not mistaken, I don't think setting up the route via the CP does the fancy advanced rule stuff described here. You'll therefore want to do that via the config/routes.php file with something like this:

'marketplace/<authorSlug:[^\/]+>/<entrySlug:{slug}>/edit' => ['template' => 'listings/_edit'],

Now authorSlug and entrySlug will be available for use in your listings/_edit.twig template...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.