TinyPortal

Development => Feedback => Topic started by: [chrisB] on March 10, 2025, 04:29:07 PM

Title: Article Category URL Generation
Post by: [chrisB] on March 10, 2025, 04:29:07 PM
I think it would be good if categories had universal URL generation.

index.php?cat=Interviews <-- tree link/breadcrumb
index.php?cat=9

One is shown in the tree link/breadcrumb.
The other in the category block, which shows on the categories page.

(https://i.imgur.com/9yOPZTD.png)

Two points:

The treelink/breadcrumb generation does not seem to be picked up by FURL mods.

If the generation of the URLs were consistent and universal, the URLs would be more formal.
Title: Re: Article Category URL Generation
Post by: @rjen on March 10, 2025, 06:14:14 PM
That may actually be an oversight.
Title: Re: Article Category URL Generation
Post by: @rjen on March 11, 2025, 11:23:35 AM
Quote from: [chrisB] on March 10, 2025, 04:29:07 PMTwo points:

The treelink/breadcrumb generation does not seem to be picked up by FURL mods.

If the generation of the URLs were consistent and universal, the URLs would be more formal.

As for point 1: I do not knwo what FURL mods are, but they are outside of the Tinyportal scope, so we cannot hekp that

For point2:
I remember that one: I have tried in the past to adapt the Cat list code to use the short description URL for the categories, but failed due to the way the code is written. This would require a more fundamental rewrite of the function, that is beyond my capabilities.

Perhaps @tino is able to help with that some time...
Title: Re: Article Category URL Generation
Post by: tino on March 11, 2025, 06:21:21 PM
Can you raise it on GitHub for me? Assign it to me and GitHub will nag me to do it  ;D

I rarely sit down at a PC anymore, but will do my best to find time.
Title: Re: Article Category URL Generation
Post by: @rjen on March 11, 2025, 10:21:10 PM
done: https://github.com/Tinyportal/TinyPortal/issues/1041
Title: Re: Article Category URL Generation
Post by: [chrisB] on March 12, 2025, 07:15:39 PM
Any chance I could be pointed to the part of the code which would generate these buttons and their URLs? Please.

(https://i.imgur.com/9yOPZTD.png)
Title: Re: Article Category URL Generation
Post by: @rjen on March 12, 2025, 07:23:08 PM
Quote from: [chrisB] on March 12, 2025, 07:15:39 PMAny chance I could be pointed to the part of the code which would generate these buttons and their URLs? Please.

(https://i.imgur.com/9yOPZTD.png)

This is the code you are looking for:

TPortal.template.php
From line 139...

// Article categories template
function template_category()
{
global $txt, $context, $scripturl;

if (!empty($context['TPortal']['clist'])) {
$buts = [];
foreach ($context['TPortal']['clist'] as $cats) {
$buts[$cats['id']] = [
'text' => 'catlist' . $cats['id'],
'lang' => false,
'url' => $scripturl . '?cat=' . $cats['id'],
'active' => false,
];
if ($cats['selected']) {
$buts[$cats['id']]['active'] = true;
}
}
echo '<div style="overflow: hidden;">' , tp_template_button_strip($buts, 'top'), '</div>';
}
Title: Re: Article Category URL Generation
Post by: @rjen on March 12, 2025, 08:32:13 PM
I just fixed it, will be in version 3.0.2
Title: Re: Article Category URL Generation
Post by: Kernal on March 15, 2025, 04:46:30 PM
Nice one @rjen

 ;)
Title: Re: Article Category URL Generation
Post by: [chrisB] on March 31, 2025, 09:28:26 PM
rjen;

Should the link, when inside an article, to view the page also be ?page=about instead of ?page=6

(https://i.imgur.com/SoSpFn2.png)

If the page has a "Short name", I would have thought for consistency, just like the categories, that the URL would be "about" and not the page's number?

I think for consistency it would make more sense, but it might be as it is intended.

In addition to this, my menu is active if I use the "article" URL, but isn't active with the page's number.

https://poetryartonline.com/?page=about

As a fix to an issue I am experiencing, it was suggested that I uninstall the Pretty URLs Pro mod. Which confirms I can make the tab active, just not with the page's ID.
Title: Re: Article Category URL Generation
Post by: @rjen on March 31, 2025, 09:40:26 PM
No, the short names are only used when displaying articles and categories. Edits are always on ID
Title: Re: Article Category URL Generation
Post by: @rjen on April 01, 2025, 07:44:01 AM
Quote from: [chrisB] on March 31, 2025, 09:28:26 PMIn addition to this, my menu is active if I use the "article" URL, but isn't active with the page's number.

That should not really matter: if you have a short name all the standard generated url's point to the page with the short name, not the ID.
And on the 'edit' page the URL is way different: instead of page it has the action: tpadmin, which highlights the TinyPortal menu option
Title: Re: Article Category URL Generation
Post by: @rjen on April 01, 2025, 08:07:50 AM
Quote from: [chrisB] on March 31, 2025, 09:28:26 PMWhich confirms I can make the tab active, just not with the page's ID.

I am assuming you are using some code to do that, like in the mod I shared.
I updated that mod to work with both Short text and ID links. See below code for an example

/**
 * Sets the current action to highlight the correct menu option
 *
 * Called by: integrate_current_action
 */
function fjrclub_current_action(&$current_action)
{
global $context, $scripturl;

// Cats
$cat_overdefjr = array('6', 'Over-de-FJR');
$cat_shop = array('18', 'Shop');
$cat_evenementen = array('17', 'Onze-activiteiten');
// Pages
$page_overdefjr = array('4', 'Geschiedenis-van-de-FJR', '75', 'Model-RP28-Ultimate', '62', 'Model-RP28', '8', 'Model-RP23', '69', 'Model-RP13A', '6', 'Model-RP13', '5', 'Model-RP08-en-RP11', '3', 'Model-RP04', '36', 'Modellen-Verenigde-Staten');
$page_shop = array('30', 'Shop', '25', 'caps-stickers-en-overige', '24', 'Kleding-met-clublogo');
$page_evenementen = array('9', 'Onze-activiteiten', '10', 'Fotohoek', '20', 'filmhoek', '83', 'Filmhoek-2022', '49', 'Filmhoek-2015', '59', 'Filmhoek-2014', '19', 'Filmhoek-2013', '18', 'Filmhoek-2012', '17', 'Filmhoek-2011', '11', 'Filmhoek-2010');

// Set the current action
if (isset($_GET['cat'])) {
if (in_array($_GET['cat'], $cat_overdefjr))
$current_action = 'Over_de_FJR';
elseif (in_array($_GET['cat'], $cat_shop))
$current_action = 'Shop';
elseif (in_array($_GET['cat'], $cat_evenementen))
$current_action = 'Evenementen';
}
if (isset($_GET['page'])) {
if (in_array($_GET['page'], $page_overdefjr))
$current_action = 'Over_de_FJR';
elseif (in_array($_GET['page'], $page_shop))
$current_action = 'Shop';
elseif (in_array($_GET['page'], $page_evenementen))
$current_action = 'Evenementen';
}
}