Home Forum
2024-12-22
Benvenuto, Ospite
Nome Utente Password: Ricordami

Replace "/component/content/article/" in URLs
(1 Online) (1) Ospite
  • Pagina:
  • 1
  • 2

ARGOMENTO: Replace "/component/content/article/" in URLs

Replace "/component/content/artic​le/" in URLs 14 Anni, 2 Mesi fa #1454

  • flint
  • Offline
  • Fresh Boarder
  • Messaggi: 6
Hi, firstly I have only been testing this plugin for the past few minutes and would like to thank the developer for making it freely available .

At the moment I am using another plugin "AutoReadMore" and one of its features is that it places a linkable image thumbnail to the left of "read more" text. The problem I am facing is that links to articles on my site are in this form (for example when the article's title is clicked):
http://example.com/sectionname/categoryid-category-categoryname/articleid-articlename.html
example:
http://example.com/news/1-latest-news/47-hello.html

However, the link assigned by the "AutoReadMore" plugin to the "read more" text thumbnail takes the following form:
http://example.com/component/content/article/articleid-articlename.html
example:
http://example.com/component/content/article/47-hello.html

This means that there are two different links to the same article within the same "read more" text. This is not only undesirable for SEO but can also be confusing to users if they wish to link to the article. What I would like is to have one format for article links. Is it possible therefore to configure RedJ to redirect all requests to:
http://example.com/component/content/article/articleid-articlename.html
to
http://example.com/sectionname/categoryid-category-categoryname/articleid-articlename.html
In other words replace the "/component/content/article/" part of URL with "/sectionname/categoryid-category-categoryname/"? Thus when users click on the "read more" thumbnail, they will see: www.example.com/news/1-latest-news/47-welcome.html instead of www.example.com/component/content/article/47-hello.html.

Thanks
L'Argomento è stato bloccato.

Re: Replace "/component/content/artic​le/" in URLs 14 Anni, 2 Mesi fa #1455

  • admin
  • Offline
  • Administrator
  • Messaggi: 1603
Hi,
you would like to automatically change:
example.com/component/content/article/articleid-articlename.html

Into:
example.com/sectionname/categoryid-category-categoryname/articleid-articlename.html

The first problem I see is that the target URL has info about category (id, name) that are not present into source, so no dynamic destination can be build.

Another problem,
you would change the link before the user click, but ReDJ does redirect, and a redirect is something that happens on server side. ReDJ can't change links into page.

I think that the best and simplest solution is to change tha way AutoReadMore creates URL (it should act as Joomla do).

Let me know if you need help about this.

Regards,
Luigi
L'Argomento è stato bloccato.
Ringraziano per il messaggio: flint

Re: Replace "/component/content/artic​le/" in URLs 14 Anni, 2 Mesi fa #1456

  • admin
  • Offline
  • Administrator
  • Messaggi: 1603
Hi Flint,
I've installed AutoReadMore 1.3 beta on my test environement, and it seems to work right. Here is an example of article and link "read more" URL:

localhost/sistemistica/notizie/1-ultime-novita/13-aggiornamento-redj-132.html

Looking at the code here is the way the URl is generated (line 72):

JRoute::_("index.php?option=com_content&id={$article->slug}")


And here is the way Joomla does:

$article->readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid));


You could change the plugin code replacing the Joomla code, but result should be the same. Could you check plugin version and Joomla SEO settings?

Luigi
Ultima modifica: 14 Anni, 2 Mesi fa Da admin.
L'Argomento è stato bloccato.
Ringraziano per il messaggio: flint

Re: Replace "/component/content/artic​le/" in URLs 14 Anni, 2 Mesi fa #1457

  • flint
  • Offline
  • Fresh Boarder
  • Messaggi: 6
Hi admin thanks for the quick response. "AutoReadMore" uses the following method for creating links attached to the thumbnail. The "read more" text-based link is fine, the problem is only with the thumbnail-based link for some odd reason. Here is code snippet which makes the thumbnail linkable:
$matches[$thumbnail] = "<a href='" . JRoute::_("index.php?option=com_content&id={$article->slug}") . "'>{$matches[$thumbnail]}</a>";


On another note, you probably miss-understood my post a bit. I don't want to change the URL but only wish to redirect it. I was looking at some examples in the RedJ documentation and here on this forum and I got the impression that RedJ was able to do string replacement when redirecting URLs with the use of macros. That is what I was hoping to achieve .

P.S. the following redirect

From URL: /component/content/article/47-hello.html
To URL: http://{siteurl}/news/1-latest-news/47-welcome.html


works fine in RedJ. I just want to do this for all URLs in these formats as group (using macros maybe or even natively via ".htaccess" Rewrite Rules) instead of creating individual items in RedJ.

Cheers
Ultima modifica: 14 Anni, 2 Mesi fa Da flint.
L'Argomento è stato bloccato.

Re: Replace "/component/content/artic​le/" in URLs 14 Anni, 2 Mesi fa #1458

  • admin
  • Offline
  • Administrator
  • Messaggi: 1603
The line of code is exactly what I've reported, and with my system I can confirm it works well.

About the ReDJ feature called "dynamic destination" you are almost right. You can build destination URL taking pieces of source URL.

What I'm trying to say is that your destination has "1-latest-news" inside. So, if this is the same for ALL the source, then you can write as costant string. But, if this need to change for any article slug, there's no rule you can use to express it. In other words, you have only article in source, but have also category and section in destination.

Maybe some new macros could solve the problem. As example {section} or {category}, but at the moment, all the macros allow only to manipulate what you have in the source matching URL.

L.
Ultima modifica: 14 Anni, 2 Mesi fa Da admin.
L'Argomento è stato bloccato.

Re: Replace "/component/content/artic​le/" in URLs 14 Anni, 2 Mesi fa #1459

  • flint
  • Offline
  • Fresh Boarder
  • Messaggi: 6
Hi Luigi thanks once again for the quick and helpful response. I was typing my second post when your second reply was posted. Actually, I was getting an error (500 - View not found [name, type, prefix]: 47welcome,html,contentView) with the original code which created the linkable thumbnail so I changed it as follows:
$matches[$thumbnail] = "<a href='" . JRoute::_("index.php?option=com_content&view=article&id={$article->slug}") . "'>{$matches[$thumbnail]}</a>";
. This worked but as mentioned, it was generating a different URL.

Upon inspection, I can see that the code you provided looks much more promising since it contains all the relevant variables . I'll try it out to and report back.
L'Argomento è stato bloccato.

Re: Replace "/component/content/artic​le/" in URLs 14 Anni, 2 Mesi fa #1460

  • flint
  • Offline
  • Fresh Boarder
  • Messaggi: 6
Hi Luigi thanks for another quick and helpful response and especially for the explanation on RedJ's "dynamic destination" feature. I did not quite understand how it works from reading the documentation and looking through the examples here. As suck I was not quite clear on what it could and could not do .

With regard to the thumbnail links, thanks to you, I have some very good news: I modified the code that I was using:
$matches[$thumbnail] = "<a href='" . JRoute::_("index.php?option=com_content&view=article&id={$article->slug}") . "'>{$matches[$thumbnail]}</a>";
by inserting yours as follows:
$matches[$thumbnail] = "<a href='" . JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid)) . "'>{$matches[$thumbnail]}</a>";
and now the links from the thumbnails are exactly the same as the those from the article's title and "read more" link. Huge thanks to you for posting the correct code

I spent quite some time researching Joomla!'s method for generating article links after I noticed that my "AutoReadmore" thumbnail links were resulting in "500" errors. I could find nothing better than the code submitted above. Anyway as has been shown, it was not quite the best. So massive thanks once again for providing the correct code .

Cheers
L'Argomento è stato bloccato.

Re: Replace "/component/content/artic​le/" in URLs 14 Anni, 2 Mesi fa #1462

  • admin
  • Offline
  • Administrator
  • Messaggi: 1603
Hi,
and thanks to you for using ReDJ.

Let me know if you need more help.

Regards,
Luigi
Ultima modifica: 14 Anni, 2 Mesi fa Da admin.
L'Argomento è stato bloccato.

Re: Replace "/component/content/artic​le/" in URLs 14 Anni, 2 Mesi fa #1463

  • flint
  • Offline
  • Fresh Boarder
  • Messaggi: 6
Thanks for the help but actually I am not using RedJ at the moment since the "AutoReadMore" plugin URL issue was solved by the above code modification .

On another note, how difficult will it be to hack Joomla!'s core code to rewrite URLs from:
http://example.com/sectionname/categoryid-category-categoryname/articleid-articlename.html
to
http://example.com/articleid-articlename.html
? I wand to like shorten URLs as much as possible display only the article name and ID, for example
http://example.com/47-hello.html.
. I am aware that extensions such as SH404SEF can do this but after looking through the reviews for this and other SEF extensions, I am concerned by the number of issues being reported by users.

Cheers
L'Argomento è stato bloccato.

Re: Replace "/component/content/artic​le/" in URLs 14 Anni, 2 Mesi fa #1464

  • admin
  • Offline
  • Administrator
  • Messaggi: 1603
To do what you want maybe it's better to use Drupal
L'Argomento è stato bloccato.
  • Pagina:
  • 1
  • 2
Moderatori: admin
Tempo generazione pagina: 1.92 secondi
Cerca con Google
News
Chi è online
 209 visitatori online
Sponsor

slotmachineaamsonline.com è una guida alle migliori slot machine online legali in Italia. Sul sito trovi un elenco sempre aggiornato dei casino online con Slot machine e bonus slot, le ultime novità dal mondo delle slot online e le migliori strategie per vincere. Inoltre, è disponibile una sezione dedicata alle slot machine da BAR che finalmente sono disponibili nella versione online.