xreadmore A widget to shorten html content to a certain length, and give a link to read for the full text.

XReadMore

A widget to shorten html content to a certain length, and give a link to read for the full text.

Use
Simple case

In the view add:

<?php
    $this->widget('ext.XReadMore.XReadMore', array(
      'model'=>$data,
		 'attribute'=>'Content',
    ));

    $this->widget('ext.XReadMore.XReadMore', array(
		 'showLink'=>false,
                 'model'=>$data,
		 'attribute'=>'Content',
		 'maxChar'=>100,
       ));
    ?>
Other Uses

There are some other parameters that could be set. The following are the list of all parameters that could be set with the widget.

public $showLink = true; // Show link to go to full text page

public $model = null; // the data model, if set use model->attribute for long text, defaults to null

public $attribute = null; // the attribute

public $text = null; // the long text, model proprty should be null to use this

public $stripTags = true; // determines whether to return plain text or html text

public $maxChar = 400; // the maximal count of character before it is truncated

public $separator = " "; // the separator to use after maxChar is satisfied

public $linkHtmlOptions = array(); // link html options.

public $allowedTags = '';

public $charset = 'UTF-8';

public $linkText = 'Read more...'; // link label, default 'Read more...'.

public $linkUrl = null; // link url.

public $return = false; //if short version will be returned or echoed.

Thanks to Usui eitalian@mail.ru for adding selective tag and encoding support.

8 0
16 followers
1 020 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: User Interface
Developed by: Blue Spy
Created on: Feb 17, 2013
Last updated: 10 years ago

Downloads

show all

Related Extensions