dynamic content in template dynamic content in template
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

dynamic content in template

Started by jawbreaker, December 15, 2006, 10:45:01 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jawbreaker

i want to display a rss feed of wordpress posts on my cpg site. i already have a working php rss script. i have added it to anycontent.php and confirmed that it works...

my cpg theme (andreas09) is a 3 column layout (sidebar|content|sidebar). i want to display the feed in the right sidebar. i know that i cannot add the php code to template.html. so how do i do this? i would like to be able to just add a tag like {RSS_FEED} where i want the feed displayed. but i have no idea how to do this.

can anyone offer some suggestions?

Gizmo

You can modify the custom include code to suit your needs.

Copy and paste this code into your theme.php file at the end before the ?>.

/**
* cpg_get_custom_include_2()
*
* @param string $path
* @return
**/
function cpg_get_custom_include_2()
{
    global $CONFIG;
    $path2 = 'rss.php'; // path to file from root
    $return = '';

    // check if the include file exists
    if (!file_exists($path2))
    {
        return $return;
    }
    ob_start();
    include($path2);
    $return = ob_get_contents();
    ob_end_clean();
    // crude sub-routine to remove the most basic "no-no" stuff from possible includes
    // could need improvement
    $return = str_replace('<html>', '', $return);
    $return = str_replace('<head>', '', $return);
    $return = str_replace('<body>', '', $return);
    $return = str_replace('</html>', '', $return);
    $return = str_replace('</head>', '', $return);
    $return = str_replace('</body>', '', $return);
    return $return;
}


Edit the path to your rss.php file in this line of the above code:$path2 = 'rss.php'; // path to file from root

If you don't have function pageheader($section, $meta = '') in your theme.php, copy and paste it from the sample theme.php file. Create a new variable under $template_vars to hold the new custom include function such as '{RSS_FEED}' => cpg_get_custom_include_2(),

Your final pageheader function will look like this:


// Function for writing a pageheader
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

    $custom_header = cpg_get_custom_include($CONFIG['custom_header_path']);

        $charset = ($CONFIG['charset'] == 'language file') ? $lang_charset : $CONFIG['charset'];

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
        header("Content-Type: text/html; charset=$charset");
    user_save_profile();

    $template_vars = array('{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . strip_tags(bb_decode($section)),
        '{CHARSET}' => $charset,
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{SYS_MENU}' => theme_main_menu('sys_menu'),
        '{SUB_MENU}' => theme_main_menu('sub_menu'),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
        '{CUSTOM_HEADER}' => $custom_header,
        '{RSS_FEED}' => cpg_get_custom_include_2(),
        );

    echo template_eval($template_header, $template_vars);
}


Place {RSS_FEED} in your template where you want it to display the feed and I'm assuming this tag will go above the {GALLERY} tag but if not, use function pagefooter().
Did you read the manual first???? Taking 2 minutes to backup your files can save you hours of wondering what you screwed up.
Billy Bullock - BullsEyePhotos Blog of Indecision

jawbreaker

thank you. i was able to make the changes you suggest. and it is reading the rss script. i'm still having trouble getting my code to run, but i think i just need to prepare it better for this method.