为joomla模块创建Readmore链接



我创建了一个非常简单的幻灯片放映模块。我有一个helper.php,它为我提供了给定类别的所有文章。我的问题是我不知道如何创建自述链接

这就是我所拥有的:

public static function getSildes() {
    // return var having the complete carousel stuff
    $slide = ""; 
    // a counter for bootstrap active flag
    $counter = 0;
    // my database connection
    $db = JFactory::getDbo();
    // i need the cat_id of category named "Bootyslide"
    $module = JModuleHelper::getModule('mod_bootyslide');
    $category = new JRegistry($module->params);
    $cat_id = (int) $category['mycategory'];
    // and now i select all the articles with the category id
    $query = $db->getQuery(true);
    $query->select('*');
    $query->from('#__content');
    $query->where('catid="' . $cat_id . '"');
    $query->where('state="1"');
    $db->setQuery((string)$query);
    $results = $db->loadObjectList();

    foreach($results as $result){
        $images  = json_decode($result->images);
        $image = $images->image_fulltext;
        $text = $result->introtext;
        $alias = $result->alias;
        $fulltext = $result->fulltext;
        ($counter == 0) ? $active = "active" : $active = "";
        $slide .= " <div class="item " . $active . "">";
        if (strlen($image) > 0) {
            $slide .= "     <img src="" . $image . "">";
        }
        $slide .= " <div class="carousel-caption">
                        <div class="container">
                            <div>
                                " . $text . "
                            </div>
                            <!-- the readmore link -->
                        </div>
                    </div>
                </div> ";
        ++$counter;
    }
    return $slide;
}

我知道当列全文有值时,我应该创建readmore链接,这不是问题所在。我真的不知道如何创建URL。

试试这个:

$id = $results->id;
$link = JRoute::_('give valid url'.$id);
$read = "<div style='text-align : $readmore_align' id='je-readmore'> <a href='$link' >". $readmore_text ."</a></div>";

相关内容

  • 没有找到相关文章

最新更新