Adding style to php output

Discussion in 'PHP' started by aleiderman, Sep 15, 2006.

  1. #1
    Hello all, having a bit of trouble modifying the style of the output from a php.

    I'm using Joomla CMS with a component called Mosets Tree.

    Theres a module called Statistics that returns the number of links that i have in my directory.

    I want to format the output but when I go look at the php code this is what i have:

    <?php

    /**
    * Mosets Tree Stats
    *
    * @package Mambo Tree 1.5
    * @copyright (C) 2005 Mosets Consulting
    * @url http://www.Mosets.com/
    * @author Lee Cher Yeong <mtree@mosets.com>
    **/

    defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

    # Include the config file
    require( $mosConfig_absolute_path.'/administrator/components/com_mtree/config.mtree.php' );

    # Get params
    $moduleclass = $params->get( 'moduleclass', '' );
    $caption = $params->get( 'caption', 'There are %s listing and %s categories in our website' ); // Default is new listing

    # Get totals
    global $mosConfig_offset;
    $now = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 );

    $database->setQuery( "SELECT COUNT(*) FROM #__mt_links "
    . "\n WHERE link_published='1' && link_approved='1' "
    . "\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '$now' ) "
    . "\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '$now' ) "
    );

    $total_links = $database->loadResult();

    $database->setQuery( "SELECT COUNT(*) FROM #__mt_cats "
    . "\n WHERE cat_published='1' && cat_approved='1' "
    );

    $total_cats = $database->loadResult();

    echo sprintf($caption, $total_links, $total_cats);

    The last line gives my output: echo sprintf($caption, $total_links, $total_cats);


    How can i format this output from sprintf?

    Thx in advance.
     
    aleiderman, Sep 15, 2006 IP
  2. Mika_

    Mika_ Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    the quickes solution would be something lihe this:
    $caption = $params->get( 'caption', '<p>There are <strong>%s</strong> listing and <strong>%s</strong> categories in our website</p>' ); // Default is new listing
    PHP:
    HTML tags provided above are just an example; use your own formatting model ;)
     
    Mika_, Oct 30, 2006 IP