1

In Craft2, I have structures that each have a landing page/homepage for that structure.

If the structure's URI format is "liver/{slug}", how do I make the 'landing page' entry have a URI of only "liver/", with no slug?

This is important since I want users visiting the liver/about-us page to be able to remove 'about-us'...and land on the liver homepage (not get a 404).

I don't understand routing very well-- from what I have gleaned I cannot see how to make routing associate a given URI with a given entry-- I only understand how to associate it with a template.

This is similar to this question, except that I want these landing pages to have dashboard entries and use the same template as all the other pages...not be an index-type page.

Note: I have seen answers regarding adding a site homepage to a structure, but this is not a site homepage- these landing pages do not live at the site domain root...they live at the root of each structure's URI.

Thanks in advance for the help.

2

You can create change the uri pattern for your structured section to something like { parent.uri }/{ slug } and create an additional entry type landing-page. Your landing page will have the slug liver and all entries below that will have the URI liver/{slug}

You can load different templates based on the entry type and if the type is your landing page, you'll display all children

Another Approach is to use a template path directly and insert the template liver.twig in your templates folder

  • Interesting idea...thank you! My hesitation is that the 'liver/' subsite encompasses a number of structures...but only one of them houses the liver homepage. So I have primary and secondary navigations...and a utility nav that includes the homepage. I will think about this and try it before marking it correct...as well as see if there are alternative suggestions. – userAW Jul 2 '18 at 17:20
  • now I marked it as correct. It worked...thank you! – userAW Jul 2 '18 at 23:40

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.