Discover the URL(s) given the article?

70 views
Skip to first unread message

Mike

unread,
Aug 28, 2012, 12:29:57 PM8/28/12
to joomla-de...@googlegroups.com
How can I get the SEF & non-sef url(s)  for an article onContentAfterSave()?

Thanks!

Mike

Mike

unread,
Aug 28, 2012, 3:15:04 PM8/28/12
to joomla-de...@googlegroups.com
I am able to get the url based on the menu/alias on the site side:

function onContentAfterDisplay($context,$article)
{
require_once JPATH_SITE . '/components/com_content/helpers/route.php';
$url = parse_url(JURI::root());
$app = JFactory::getApplication();
$app->enqueueMessage($url['scheme'].'://'.$url['host'].JRoute::_(ContentHelperRoute::getArticleRoute($article->id,$article->catid)));
}

But on the administrator side onContentAfterSave(), where I need it, I'm getting a non-sef url.  Is there some way to get the menu/alias path on the admin side?

Best,

Mike

Swapnil Shah

unread,
Aug 28, 2012, 5:12:34 PM8/28/12
to joomla-de...@googlegroups.com
Why are you trying to get a SEF URL on admin side? Reason I ask is because admin side is not setup for SEF urls. 

You can off course predict the SEF URL from admin side. 

You will probably get that information from the item object. Before / after it is saved. 


Regards, 


Neil
Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/x07ctOQwNJwJ.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

Mike Pearl

unread,
Aug 28, 2012, 5:57:26 PM8/28/12
to joomla-de...@googlegroups.com
I'm writing a plugin which, when an article is published from within the admin-side, will read the site-side page and rewrite it as a static html file.  Bear in mind this is not for a production site, but rather as part of a scalability test.

Mike

Swapnil Shah

unread,
Aug 28, 2012, 6:09:43 PM8/28/12
to joomla-de...@googlegroups.com
Hey mike, 

Why write another plugin when there is one that already ships with joomla? I believe it's a system plugin. It will cache an entire page the first time it is request. In essence creating static HTML. If you need to rework that page, you would have to clear your cache. 

I assume you want to do this so you can have a specific URL? For that you'd be better of writing a system plugin that works on the URL instead of worrying about creating a static HTML page. 

Just had a thought, the rewrite component + plugin might be what you are looking for. 


Regards, 


Neil
Sent from my iPhone

Mike Pearl

unread,
Aug 28, 2012, 6:29:19 PM8/28/12
to joomla-de...@googlegroups.com
I'm not sure why, but the team doing the test didn't like the way the page cache worked.  I think they wanted the cache page created when the content was first published and after each updates rather than when first rendered.

Mike
Reply all
Reply to author
Forward
0 new messages