Recent Topics

1 Sep 23, 2005 18:27    

I upgraded to the 0.9.1b Dawn release yesterday (great work, by the way, performance is much improved) and moved my skin across and noticed that I was getting a validation error on a post where I had chosen to link to another site in the title, rather than the permalink.

The skin code in _main.php for the storytitle class was:


<h3 class="storytitle"><a href="<?php $Item->permalink() ?>" rel="bookmark" title="<?php echo T_('Permanent link to full entry') ?>"><?php $Item->title(); ?></a></h3>

But by selecting a different link altered the output from $Item->title() to include a <a> tag, thus invalidating the markup for XHTML 1.1.

To fix this I removed the call to $Item->permalink() in the skin code above and changed b2evocore/_class_item.php::title() to:


  function title(
    $before='',           // HTML/text to be displayed before title
    $after='',            // HTML/text to be displayed after title
    $add_link = true,     // Added link to this title?
    $format = 'htmlbody' )
  {
    if( empty($this->title) && $add_link )
      $title = $this->url;
    else
      $title = $this->title;

    if( empty($title) )
    { // Nothing to display
      return;
    }

    $title = format_to_output( $title, $format );

    if( $add_link && (!empty($this->url)) )
    {
      $title = '<a href="'.$this->url.'">'.$title.'</a>';
    } else
    { /* GJW */
      $title = '<a href="'.$this->gen_permalink().'" rel="bookmark" title="Permanent link to full entry">'.$title.'</a>';
    } /* GJW */

    echo $before;
    echo $title;
    echo $after;
  }

This fixes the validation error, makes the skin code a little bit simpler and removes a function call overhead thus improving performance a teeny bit more :)

Cheers, Greg.

2 Nov 11, 2005 20:51

While this may make the XHTML validate, adding this fix breaks validation for Atom/RSS/RDF.

(Try the validation buttons in the custom skin)

3 Nov 11, 2005 23:22

Somewhere in my "everything" skin I offer a method that uses the skin to decide what to link the title to. Basically, if the 'link to url' field is empty it will link to the post, but if that field is not empty it will link to the content of that field. http://forums.b2evolution.net/viewtopic.php?t=5077 is the post that talks about that 'skin'.

The specific code that will decide where to link the title is this:

<?php 
/**
 * linking the title to the permalink if there is no other url
 */
if( $Item->get('url') ) {
	$Item->title();
	} else { ?>
	<a href="<?php $Item->permalink() ?>" title="<?php echo T_('Permanent link to full entry') ?>"><?php $Item->title( '', '', false ); ?></a>
	<?php } ?>

Clearly you have to put it where it belongs and have your tags and classes and whatnots, but the idea is pretty simple and addresses this "bug" at the skin level. Well, I *think* it addresses this issue. I don't use a skin that permalinks the title, so I've only got a bit of tinkering experience with the issue.


Form is loading...