1

I'm in a situation where I have to build a url like :

{path='template/group/category/{category_url_title}'}

Now, if someone changes the category trigger word in the control panel, this URL will lead to a 404. I wonder if there is any undocumented? variable that would give me the category trigger word, without enabling php in the template ?

0

No, there isn't, but maybe you don't need one or, if you really need, you can create one.

The docs says:

The category designation information will automatically be added to the end of the URL so that the target page will know which category to display.

So, inside of a {categories} variable pair, the necessary info will be added and you don't need to worry about it.

If you still want to prevent the user from changing this, you can override this setting on the config.php file:

$config['reserved_category_word'] = 'category';

Now, this setting can't be changed on Admin › Channel Administration > Global Channel Preferences. But it can still be changed on Admin > System Administration > Config File Editor.

If you still need the variable, you can create it. Back on the config.php, after you set the $config['reserved_category_word'], add this before // END EE config items:

/**
 * @see  https://gist.github.com/464756
 */
global $assign_to_config; // Make this global so we can add some of the config variables here

// make sure our global vars config exists
if(!isset($assign_to_config['global_vars']))
$assign_to_config['global_vars'] = array();

And them create your variable:

$assign_to_config['global_vars']['cv-category_word'] = $config['reserved_category_word'];

I prefixed the variable with cv- to make it easier to remember where it was set, a Config Variable, but you can use the name you prefer.

You can access this variable on your templates: {cv-category_word}.

Remember that you can always set which parts of the CP the user can have access to.

| improve this answer | |
  • Or you can make one global variable in index.php {reserved_cat_word} and use that in your templates. When the word changes, you only have to change the global assigned variable once. – GDmac Jun 18 '14 at 8:13
  • @GDmac, this is almost the same I said. I believe that to keep these variables on the config.php is better than on the index.php: to keep all stuff in one place. But if you disagree, feel free to improve the answer. Your English is probably better than mine. Thanks. – Robson Sobral Jun 18 '14 at 12:42
0

Presumably, you're creating this URL inside of a {categories} loop - in which case you simply need to do this:

{path="template/group"}

This will output /template/group/category_trigger/category_url_title.

| improve this answer | |
  • I'm not inside a regular categories tag, hence this specific question. – laurent Jun 14 '14 at 13:36

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.