News Show Pro GK5 > Options > Info. Blocks

Rate this topic: Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.1.00 out of 6 based on 1 vote(s)
GK User
Tue Oct 01, 2013 8:12 pm
Reply with quote
Report this post
Hi you all,


I'm microdating the site with the microdate schema.org and I need to insert some attributes inside the tags in order to google for indexing my pages.

What I did is:

1) Going to the Module Manager --> News Show Pro GK5 --> Options --> Article layout --> Information Block
And set --> (Info format: %DATE ; Second Info format:%AUTHOR)

2) In this file modules\mod_news_pro_gk5\tmpl\com_k2\view.php I add the microdate in this line $news_info = '<span class="source-org vcard" itemscope itemtype="http://schema.org/Person"><a itemprop="url" href="https://plus.google.com/107729283876695900158" rel="author"> <p itemprop="name" class="fn org nspInfo '.$class.'">'.$config['info'.(($num == 2) ? '2' : '').'_format'].'</p></a></span>';

What I need to do is to differentiate either the author from the date but I found that they are created jointly in this line if($config['news_content_info_pos'] != 'disabled') {
$class = 'updated nspInfo1 t'.$config['news_content_info_pos'].' f'.$config['news_content_info_float'];
}
} else {
if($config['news_content_info2_pos'] != 'disabled') {
$class = 'fn url org nspInfo2 t'.$config['news_content_info2_pos'].' f'.$config['news_content_info2_float'];
}

So I can add the class for the microformating hAtom but I can't access the tag to insert the attributes for the schema separately one from another.

Do you know some way to fix it? I thought the posibility to create a js scritp to parse the page and insert the attribute when the page is rendered but I don't know if this is a good idea.

Thanks!
User avatar
Senior Boarder

teitbite
Wed Oct 02, 2013 3:33 pm
Reply with quote
Report this post
Hi

Sorry, but the code is a little out of context and I do not understand what You mean. Author an data are being constructed with a MASK so You should be able make Your changes during this process.
User avatar
Moderator

GK User
Thu Oct 03, 2013 12:23 am
Reply with quote
Report this post
The context is in this file: modules\mod_news_pro_gk5\tmpl\com_k2\view.php
The original code is this:
Code: Select all
   // article information generator
   static function info($config, $item, $num = 1) {
      // %AUTHOR %DATE %HITS %CATEGORY
      $news_info = '';
      //
      if($num == 1){
         if($config['news_content_info_pos'] != 'disabled') {
            $class = 'nspInfo1 t'.$config['news_content_info_pos'].' f'.$config['news_content_info_float'];   
         }
      } else {
         if($config['news_content_info2_pos'] != 'disabled') {
            $class = 'nspInfo2 t'.$config['news_content_info2_pos'].' f'.$config['news_content_info2_float'];
         }         
      }
      //
      if(
         ($config['news_content_info_pos'] != 'disabled' && $num == 1) ||
         ($config['news_content_info2_pos'] != 'disabled' && $num == 2)
      ) {
           $news_info = '<p class="nspInfo '.$class.'">'.$config['info'.(($num == 2) ? '2' : '').'_format'].'</p>';


The structure of microformat and microdate is (no matter the html tags are):
Code: Select all
<div itemscope itemtype="http://schema.org/Person" itemprop="author" class="sourge-org vcard">
   <p itemprop="name" class="fn org"><a href="authorLink" itemprop="url" class="fn url org"></a></p>
        <p itemprop="datePublishe" class="updated"></p>
</div>


The problem I have is that the <p> tag for the author and the date are created here
Code: Select all
$news_info = '<p class="nspInfo '.$class.'">'.$config['info'.(($num == 2) ? '2' : '').'_format'].'</p>'


So I can’t add microdate and microformat separately and I don’t have the link of the author.

The first post was the code I modified in order to implement microdate and microformat but it’s wrong because the date is recognized buy google like an author so I need to identify which <p> is the author and which <p> is the date so I can add the attributes I need.
User avatar
Senior Boarder

teitbite
Sat Oct 05, 2013 3:33 pm
Reply with quote
Report this post
Hi

Sorry, but looking at this code is not giving me any ideas how to solve it. Please send me FTP access so I'll make some dump, see values returned and maybe some easy string permutation will help to separate it.
User avatar
Moderator

teitbite
Sun Oct 06, 2013 2:24 pm
Reply with quote
Report this post
Hi

I need one small information more :) Please tell me where is the module You are trying to make this be used this way. I thought it's going to be easy to find it, but You have over 50 modules of this type :)

Please tell me the page I can see it and ID if there is more modules of this type on this page.
User avatar
Moderator

GK User
Sun Oct 06, 2013 9:23 pm
Reply with quote
Report this post
Hi,

Yes, we use the module many times in all pages... We need this to be change for all of them.

An example could be this page: http://www.managementjournal.net/top-management

A quién le interesó TOP Management, también le interesó ...
Mod. ID : 689

Columnistas
Mod. ID: 767

Lo más reciente
Mod. ID: 762

Quién leyó esto, también leyó:
Mod. ID: 713
User avatar
Senior Boarder

GK User
Sun Oct 06, 2013 9:26 pm
Reply with quote
Report this post
Is this what you mean?
User avatar
Senior Boarder

teitbite
Tue Oct 08, 2013 6:28 pm
Reply with quote
Report this post
Hi

I must say I had a lot of problem to solve it. While it was pretty simple, just the way You started was not the easiest solution. Please revert Your changes and make it this way:

1. Edit file: /modules/mod_news_gk5/tmpl/com_k2/view.php and around line 213 You will find code like:

Code: Select all
           $news_info = str_replace('%AUTHOR', $info_author, $news_info);
           $news_info = str_replace('%DATE', $info_date, $news_info);
           $news_info = str_replace('%HITS', $info_hits, $news_info);
           $news_info = str_replace('%CATEGORY', $info_category, $news_info);
           $news_info = str_replace('%RATE', $info_rate, $news_info);
           $news_info = str_replace('%COMMENTS', $info_comments, $news_info);
           $news_info = str_replace('%TAGS', $info_tags, $news_info);


2. Please replace it with:

Code: Select all
           $news_info = str_replace('%AUTHOR', '<span itemprop="author">'.$info_author.'</span>', $news_info);
           $news_info = str_replace('%DATE', '<span itemprop="date">'.$info_date.'</span>', $news_info);
           $news_info = str_replace('%HITS', $info_hits, $news_info);
           $news_info = str_replace('%CATEGORY', $info_category, $news_info);
           $news_info = str_replace('%RATE', $info_rate, $news_info);
           $news_info = str_replace('%COMMENTS', $info_comments, $news_info);
           $news_info = str_replace('%TAGS', $info_tags, $news_info);
User avatar
Moderator

GK User
Wed Oct 16, 2013 11:48 pm
Reply with quote
Report this post
That was really cool!!! Thanks you very much!!!

I have a little more question, is it possible to add a dynamic link to the author? I can add a static one, but that’s not the point.

I found in the helper “gk.format.parser.php” the next code

Code: Select all
         {TITLE} - article title
         {TEXT} - article text
         {URL} - article URL
         {IMAGE_SRC} - article image URL
         {AUTHOR_EMAIL} - article autor e-mail
         {AUTHOR_NAME} - article author name
         {CATEGORY} - article category name
         {CATEGORY_URL} - article category URL
         {HITS} - article hits
         {DATE} - article date
         {RATING} - article rating


Is from there that the module gets the data?
User avatar
Senior Boarder

teitbite
Sat Oct 19, 2013 4:27 pm
Reply with quote
Report this post
Hi

I think I got it :) In the same file, line 180:

Code: Select all
$info_author = ($config['user_avatar'] == 1) ? '<span><img src="'.K2HelperUtilities::getAvatar($item['author_id'], $item['author_email'], $config['avatar_size']).'" alt="'.$author.' - avatar" class="nspAvatar" width="'.$config['avatar_size'].'" height="'.$config['avatar_size'].'" /> '.$author.'</span>' : $author;


try add this just after:

Code: Select all
$info_author = '<a href="index.php?option=com_k2&view=itemlist&layout=user&id=' . $item['author_id'] . '&task=user">' . $info_author . '</a>';
User avatar
Moderator

GK User
Tue Oct 22, 2013 5:24 am
Reply with quote
Report this post
Great!!! Thanks a lot :D
User avatar
Senior Boarder


cron