Putting title attributes in page list links

Permalink
For SEO purposes, I need to add a title attribute to all the URLs for pages in a page list. Currently, the URL structure is simply

<a  href="sitename/name-of-category/title-of-article/">Title of Article</a>


I need it to read like this:

<a  href="sitename/name-of-category/title-of-article/" title="Title of Article">Title of Article</a>


I tried to accomplish this by making a custom template for the Page List block with a single change in it...from this:

<a <?php  if ($target != '') { ?> target="<?php echo $target?>" <?php  } ?> href="<?php echo $nh->getLinkToCollection($cobj)?>">


...to this:

<a <?php  if ($target != '') { ?> target="<?php echo $target?>" <?php  } ?> href="<?php echo $nh->getLinkToCollection($cobj)?>" title="<?php echo $title?>">


...and that worked to put the title attribute in the anchor tag. But it stripped the quotation marks from the href. The link still works all right, but it looks like this:

<a  href=sitename/name-of-category/title-of-article/ title="Title of Article">Title of Article</a>


I'm not a programmer...does anyone here know why this happened? Because it works it may not be too serious; but I just want to have the cleanest source code possible.

1db
 
CC3381 replied on at Permalink Reply
CC3381
What version of C5 are you using and did you copy the page_list block from the concrete/blocks/ folder to the blocks/ directory. In the /bocks/page_list/view.php file I do not find the code you are trying to adjust. I did find the code below that is used to display the page links in a list block. I just added the title section as you would want. Please let me know if you need additional help.

File: view.php
Line 50 - 53
/* The HTML from here through "endforeach" is repeated for every item in the list... */ ?>
      <h3 class="ccm-page-list-title">
         <a href="<?php  echo $url ?>" target="<?php  echo $target ?>" title="<?php  echo $title ?>"><?php  echo $title ?></a>
      </h3>
1db replied on at Permalink Reply
1db
This is in 5.4.1.1. Same path: concrete/blocks/page_list/view.php.
1db replied on at Permalink Reply
1db
And I tried that approach anyway, just in case it might work. It didn't...it stripped away the href entirely, giving me this:

<a href="" title="Title of Article" />


...probably just because it's the wrong approach for 5.4.1.1.
CC3381 replied on at Permalink Reply
CC3381
Strange, I tried it on a fresh install of 5.4.1.1 , 5.4.2.1 and 5.5.1 and worked just fine.