SPECIAL OFFER: Only $69 for access to everything in OSTraining for 1 year! You save $75! 
Join today and get access to 1,000's of books and videos. Learn WordPress, Drupal, Magento, Joomla and more! Sign up today!

including Joomla article ID# in the page source

5 years 7 months ago #123230 by emilylu
Hi,

Is there a way we can add/include each article ID# in the page source code?
Not in the page url but in the source code of the page?

Thanks,
Emily

Please Log in to join the conversation.

5 years 7 months ago #123234 by Valentin
Hi Emily,

Do you have a template override for single articles? If so, edit the file located in templates/yourtemplate/html/com_content/article/default.php

Print this snippet in somewhere:
article-id-<?php echo $this->item->id; ?>

It could be inside a div as a class:
<div class="article-id-<?php echo $this->item->id; ?>" >

So, it would print like:
<div class="article-id-99" >

Kind regards,
Valentín

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining
The following user(s) said Thank You: emilylu

Please Log in to join the conversation.

5 years 7 months ago #123289 by emilylu
Hi Valentin,

So I added the php code
<article-id-<?php echo $this->item->id; ?>
in the template default.php

however, when i check the source code of the article, the ID didn't match with the article ID... not sure why?
For example on this page: district279.org/about-us/corrections-clarifications
The page ID in the source code shows #775
<html lang="en-us" dir="ltr" class='com_content view-article itemid-775 j34 mm-hover'>
But in the admin backend id is #757:
district279.org/administrator/index.php?...e&layout=edit&id=757

And it's the same way for other pages I check randomly, Any ideas why it didn't match? Thanks!

Please Log in to join the conversation.

5 years 7 months ago #123301 by Valentin
Hi Emily,

Note, the code you added is broken the HTML:
<article-id-number

Be sure to add as a class, maybe inside <aside> tag, so, it would print in this way:
<aside class="article-aside clearfix article-id-number">

Note, in your sample code you have a reference to itemid, which is different to the article id:
<html lang="en-us" dir="ltr" class='com_content view-article itemid-775 j34 mm-hover'>

Kind regards,
Valentín

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining

Please Log in to join the conversation.

5 years 7 months ago #123303 by emilylu
Got it. Thanks!

Please Log in to join the conversation.

5 years 7 months ago #123323 by Valentin
I'm happy to help, Emily!

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining

Please Log in to join the conversation.

Join today and get access to 1,000's of books and videos. Learn WordPress, Drupal, Magento, Joomla and more! Sign up today!