2

I've scouring through StackExchange looking for an answer for the last few days with no luck.

These are the suggestions that I've seen without any real detail or resources: 1.) Somehow use the index page of a template group to handle this. Once again, no direction given on how one would do this.

2.) Use Template Router plugin on Devot:ee - Looks like it's primarily for blog functionality. I don't see any real clear documentation on how this plugin works.

3.) Use Pages module - doesn't work. I've gone through all of the documentation. Can't get it to work, plus I am not fond of the idea of manually changing links. Would love to have template groups removed automatically without requiring my client to take extra steps to remove this URL segment.

4.) Use Freeway extension - tried installing... doesn't appear in extension section once it's uploaded plus it has a bunch of tickets open for breaking other modules, etc.

5.) .htaccess - haven't found anything that works except to remove the index.php file - plus my understanding is that .htaccess isn't necessarily the most reliable way of approaching this sort of issue?

In short, how in the world do you remove the template group from the URL structure... I've heard the arguments that it somehow makes for a better user experience to include this, but for me, it's not the case. I use very generic names for my template groups; e.g., content_page, general_page, etc.

Someone, please tell me there's an easy way to work around this?

  • Are u looking to use just single URL titles throughout your site forever like my site.com/an_entry_title or will you require sub sections like my site.com/news/an_entry_title ? – stuartmcd69 Dec 30 '13 at 7:01
  • Just looking to remove the template group name from the URL structure; e.g., site.com/template_group/about-us – Justin Meyers Dec 30 '13 at 7:05
2

If you wanted to use Template Routes, here's how you'd do it:

$config['template_routes'] = array(
  'about-us' => 'template_group/about-us',
  'faq' => 'template_group/faq',
);

This will make it so if you visit the http://yoursite.com/about-us url, you'll get the template_group/about-us template.

  • Thanks for the reply, Rob. I put the following in the bottom of my config file without any luck: $config['template_routes'] = array( 'about' => 'training_page/about', ); The Template Router extension is enabled. Not sure what I'm missing? This is the particular page I'm working with here: biomechaniks.com/training_page/about If I have to follow the example you shared, that means I have to have a template route config writeup for each individual page? Thanks for the help, sir :) – Justin Meyers Dec 30 '13 at 18:10
  • Correct about needing a line for each template. Not sure why you're getting a white screen of death at /about. There's probably a suppressed PHP error causing it. Crack open index.php and set $debug to 1 and then see if you can spot the error message. – Rob Sanchez Dec 30 '13 at 18:21
  • Having one for each template isn't that bad. I was thinking I needed one for each page! That would be terrible :) Per your suggestion, I placed the $debug at the top of my index page and didn't get any kind of php readout. I use my index page in my template groups as the actual template if that helps sort things out? I know people just use the index page to point to other pages within the group, I haven't graduated to that yet. Hope that makes sense? Thanks! – Justin Meyers Dec 30 '13 at 18:42
0

This is one of those questions where there is no 'silver bullet' approach. The most flexible method is using the partials or DRY approach but this is fairly in depth and prone to overuse or misuse.

Another approach would be to create a series of globals or snippets to markup the pages without the need for calling on structural templates, it requires re-creating the base template for every page but it's not that difficult. I;d use one of the modules that allows snippets to be edited as text files and in this example I'm referring to snippet sync.

SNIPPET based template:

<html>
{snip:css}
<body>
{snip:navigation}
  //Content lives in here
{snip:footer}
{snip:js}
</body>
<html>

Then using the following template structure, you'd simply copy/paste that above into each template.

  - about.group
      index.html
  - news.group
      index.html
      detail.html

About + News would render as mysite.com/about + mysite.com/news and mysite.com/news/detail/url_title_lives_here. YOu can use the default index.html file to do advanced URL testing and present different data dependant on but thats more advanced again.

It's a broad question but this is the simple approach, it can quickly get complicated dependant on your data but this should start you on a path :)

  • Thanks @Stuartmcd69 - I'm going to have to chew on this for a bit... You seem to know your stuff :) I read the the links you shared. There definitely is another level of EE I'm not even tapping into. What are some of the EE modules that allow you to edit snippets as text files? Or better yet, which one do you recommend? I appreciate your response because unknowingly you piqued my interest in changing the way I setup EE sites. So for that, thank you! I'm a pretty solid front-end developer, but get a little intimidated with some of the more advanced EE setups. Thanks! – Justin Meyers Dec 30 '13 at 18:19
0

Take a look at Structure; I use it on almost every EE project I build, much better than the Pages module, and, it has a great UX/UI for managing content, and it's pretty flexible (works with standard template groups when you need to, otherwise takes care of them). Also does some neat things like build navigation trees, etc.

  • Hey @nickbenson thanks for the advice. Yes, I typically use structure. However, as I understand it, all the url control is done manually; e.g., when you add a page, you basically type in the url structure you would like to use? Trying to keep things as hands free for the client side as possible... – Justin Meyers Jan 2 '14 at 18:48
  • URL segments in Structure are generally just the URL titles of the entries/pages you've created, which you can then shuffle around and nest to create parent/child relationships. If you had "Jack" and "Jill" as child pages of "People," the URLs for both would automatically be /people/jack and /people/jill, and the templates for both would be whatever was specified in Structure's preferences. – Nick Benson Jan 2 '14 at 18:56

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.