0

I've created a very simple slideshow module. I have a helper.php that gives me all articles of a given category. My problem is that i don't know how to create the readmore link.

That's what i have:

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;

}

I know that when the column fulltext has values, I should create the readmore link, that's not the problem. I really don't know how to create the URL.

DaFunkyAlex
  • 1,859
  • 2
  • 24
  • 36
  • 1
    Try asking for your question over at [Joomla Stack Exchange](http://joomla.stackexchange.com) ;) – Lodder Feb 18 '15 at 10:25
  • done, thank you: [link]http://joomla.stackexchange.com/questions/8681/create-readmore-link-for-custom-module[/link] – DaFunkyAlex Feb 18 '15 at 12:14

1 Answers1

0

Try this:

$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>";
AJPerez
  • 3,435
  • 10
  • 61
  • 91
Jextn
  • 101
  • Dude!!He already got the answer here -- [http://joomla.stackexchange.com](http://joomla.stackexchange.com/questions/8681/create-readmore-link-for-custom-module) – Arcanyx Jun 09 '15 at 07:57