LifeType 中文開發論壇

開發 => 核心補強精華區 => 主題作者是: ericj 於 十月 01, 2005, 02:10:25 下午



主題: 點選"閱讀全文"時focus在延伸內文那一部份
作者: ericj十月 01, 2005, 02:10:25 下午
修改  class/view/defaultview.class.php

程式碼:
function _addShowMoreLink()
{
    $posts = $this->_params->getValue( 'posts' );
    $locale = $this->_blogInfo->getLocale();

    //$textFilter = new TextFilter();
    $modifPosts = Array();
    $rg = RequestGenerator::getRequestGenerator( $this->_blogInfo );
    foreach( $posts as $post ) {
    if( $post->hasExtendedText()) {
          $result = $post->getIntroText();
          $showMoreText = $locale->tr( 'read_more' );
+         // patch for read more text focus by ericj.
!         $showMoreLink = "&nbsp;<a href=\"".$rg->postPermalink($post)."#More\">".$showMoreText."</a>";
          $post->setText( $result. $showMoreLink );
    }

    array_push( $modifPosts, $post );
}


view/viewarticleview.class.php

程式碼:
function render()
{
    // if our view is cached, there is not much to do here...
    if( $this->isCached()) {
    parent::render();
    return true;
    }

    // get the next and previous articles, based on the article we're going to show
    $article = $this->getValue( 'post' );

    // notify of certain events
    $postText = $article->getIntroText();

+   // patch for focus by ericj
!   $postExtendedText = "<a name="."\"More\"></a>".$article->getExtendedText();

    #$postExtendedText = $article->getExtendedText();
    $this->_pm->notifyEvent( EVENT_TEXT_FILTER, Array( 'text' => &$postText ));
    $this->_pm->notifyEvent( EVENT_TEXT_FILTER, Array( 'text' => &$postExtendedText ));
    $article->setIntroText( $postText );
    $article->setExtendedText( $postExtendedText );
    // and yet one event more
    $this->_pm->notifyEvent( EVENT_POST_LOADED, Array( 'article' => &$article ));

    // once ready, put the article back to the context of the view
    $this->setValue( 'post', $article );
    $this->setValue( 'comments', $article->getComments());
    $this->setValue( 'user', $article->getUser());
    $this->setValue( 'trackbacks', $article->getTrackbacks());

    // render the main view
    parent::render();
}



主題: Re: 點選"閱讀全文"時foucs在延伸內文那一部份
作者: markwu十月 03, 2005, 01:38:19 下午
Hi ericj:

謝謝!我把他移到精華區中。 :-D

Mark