1

How to set a root article as sub-path URL for children articles?

Meaning, I have a root page named article0, and article{1-100} under this root article.

I want to display the article0 under the URL website.wb/article0, but also website.wb/article0/article{1-100}under the former…

For now, I can put articles under article0, but I cannot get the corresponding URL… And seems I cannot use Hidden Menus and Categories to get the result.

So is there any solution built-in in Joomla, or I have, at least, to override /components/com_content/category, or coding components, etc…


Edit

The above mentioned override of com_content/category/, is to put in default.php this content:

    <?php
    $table_plan         = JTable::getInstance('Content', 'JTable');
    $table_plan_return  = $table_plan->load('2');
    echo $table_plan->introtext;
    ?>

where '2' is the id of the root article. Then I put this category as link in the wanted menu.

1
  • I flinched when I saw this. A Hardcoded ID is exposed to all sorts of Bad Things that can happen when databases need to be repaired, rebuilt, or migrated. Still it's your site, your maintenance time, so if you think it's worth it, I'll not argue the point.
    – Arlen
    Aug 14, 2019 at 19:10

1 Answer 1

1

Ok, this is a bit hack-ish, but it can work:

Set article0 as a category itself, not as an article. Use the Category Description field to hold what you currently have as the article text.

Set article1-100 as articles in the category. That way /article0 is the category (Blog or List) page, and the rest are /article0/articlex as articles within that category.

Joomla likes to list articles on the category page (the Category Blog menu item type might be able to be convinced to display 0 articles, haven't tested it). That means you will probably have to write a template override in order to do a clean display of it.

That's the simplest solution I can see, at the moment, unless you can find a third party SEF URL generator that will use menu item parent/child relationships to build the URLs. Other ideas are using a third-party generator to manually create all 101 URLs you're talking about (can be done, but seems tedious to maintain) or writing your own SEF extension to do what you want.

2
  • I have added what I mean by 'override'. But, your solution, as mine, seems wired. Indeed, I hope? there is a built-in solution in Joomla…
    – JDoe
    Aug 13, 2019 at 15:43
  • The template override I spoke of would be either just the default category list template file or (probably better) creating your own layout for your template to use. Don't think there's a built-in solution, simply because the idea of a parent-child relationship between articles is completely foreign to Joomla (and to me, for that matter). Joomla was designed with idea that relationships between articles would be expressed via categories and menu items (and, to a lesser extent, tags).
    – Arlen
    Aug 13, 2019 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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