coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 themes/skins/templates => Topic started by: tyio on July 02, 2006, 06:34:52 PM

Title: Include php files, into the template
Post by: tyio on July 02, 2006, 06:34:52 PM
hi every one :)



as the title says, i have probleme to call the php files, into a div, previously done


i edit the theme.php, adding :

Quote<td class="element_news"><a href="news_host.php" title="{FORUM_NEWS}">{FORUM_LNK}</a></td>


but just do a link, but the link is into the div (sized with the css)


i would like to know, if there is another solution, because, when i use

include "XXX.php", i can see the text into the div (editing theme.php),and the page doesn't show .....


For information, the page is a code, to call information, from a phpBB2 forum, and so, calling a page isn't the only solution, if i can add all code php ??

thanks :)
Title: Re: Include php files, into the template
Post by: tyio on July 02, 2006, 06:42:58 PM
when i past the code directly into theme.php :

i have this message :
Quoteparse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/alternc/html/t/tyio/themes/tyio/theme.php




the line of the probleme is :


Quoteecho '<h2><font size=+0>'.$data['topic_title'].'</h2>';
,

quite a simplar line ^^


thanks for helping :)
Title: Re: Include php files, into the template
Post by: Sami on July 02, 2006, 07:33:19 PM
you can add your {FORUM_NEWS} and {FORUM_LNK} to your theme.php
first you need to know where do you want to put your code

- if you want put it before {gallery} (it's in template.html) you should edit pageheader() function on your theme.php or if you need put code after {gallery} you should edit pagefooter() function

let's do this by editing pageheader()

1. check your theme.php , if you don't have a pageheader() function on your theme.php then you should copy it from themes/sample/theme.php
2. add your {FORUM_NEWS} and {FORUM_LNK} to "$template_vars" so your $template_vars should be look like this:


$template_vars = array('{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . strip_tags(bb_decode($section)),
        '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['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,
        '{FORUM_NEWS}' => "your title", //moded for custome theme
        '{FORUM_LNK}'=> "your URL",
        );


3. add your title and URL between ""
4. don't forget to put {FORUM_NEWS} and {FORUM_LNK} to your template.html (remember you need to put them before {gallery} in this example)
Title: Re: Include php files, into the template
Post by: tyio on July 02, 2006, 08:03:30 PM
hi :)

thanks for your quick anwer :)



no pb with what you tell me to do, but, doesn't open the page, just put the url, into the template, but no what the files contain ;(


here what i do


Quotefunction 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']);

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    user_save_profile();

$template_vars = array('{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . strip_tags(bb_decode($section)),
        '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['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,
        '{FORUM_NEWS}' => "Forum tyio", //moded for custome theme
        '{FORUM_LNK}'=> "http://tyio.hostarea.org/news_host.php",
     
        );

    echo template_eval($template_header, $template_vars);
}



and here what i have

http://tyio.hostarea.org/ (http://tyio.hostarea.org/)




thanks anyway :)
Title: Re: Include php files, into the template
Post by: Sami on July 02, 2006, 08:08:22 PM
did you add "<td class="element_news"><a href="news_host.php" title="{FORUM_NEWS}">{FORUM_LNK}</a></td>" to your template.html?
Title: Re: Include php files, into the template
Post by: tyio on July 02, 2006, 08:13:25 PM
:)

if i had this line in the template.html files, i have a div, with the link into it :)

and when i click into the link, got an error ....$



QuoteFatal error: Cannot redeclare make_clickable() (previously declared in /var/alternc/html/t/tyio/include/functions.inc.php:539) in /var/alternc/html/t/tyio/phpBB2/includes/bbcode.php on line 617



but this is another story ^^
Title: Re: Include php files, into the template
Post by: Sami on July 02, 2006, 09:36:48 PM
what do you exactly want to do?
post the proper code you want to inject and I'll give you the solution ....
Title: Re: Include php files, into the template
Post by: tyio on July 02, 2006, 09:41:58 PM
i want to add a windows, which sho the information from a forum


here the code , i notice i don't put the database information but on my real try, the files works :
http://tyio.hostarea.org/news_host.php (http://tyio.hostarea.org/news_host.php)


Quote<?
define('IN_PHPBB', true);
$phpbb_root_path = 'forum/';
$theme = 'subSilver';
include_once($phpbb_root_path.'includes/template.php');
include($phpbb_root_path.'includes/functions.php');
$template = new Template($phpbb_root_path.'templates/'.$theme);
include_once($phpbb_root_path.'includes/bbcode.php');

$host = "localhost";
$user = "root";
$pass = "";
$bdd = "phpbb"; // votre base de donnée
   
@mysql_connect($host, $user, $pass);
@mysql_select_db("$bdd") or die("Impossible de se connecter");

$table_prefix = 'phpbb_';
$sql = "SELECT t.topic_id, t.forum_id, t.topic_title, t.topic_time, t.topic_replies, t.topic_last_post_id, t.topic_views, t.topic_vote, u.username, u.user_id, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_allowsmile, p.*,  pt.post_text, pt.post_subject, pt.bbcode_uid
   FROM " . $table_prefix. "forums f, " . $table_prefix. "topics t, " . $table_prefix. "posts p, " . $table_prefix. "users u, " . $table_prefix. "posts_text pt
   WHERE f.forum_news = '" . TRUE . "'
      AND t.forum_id = f.forum_id
      AND p.topic_id = t.topic_id
      AND p.post_id = t.topic_first_post_id
      AND pt.post_id = p.post_id
      AND u.user_id = p.poster_id
      AND t.topic_type = '0'
   ORDER BY topic_time DESC";

$req = mysql_query($sql);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>j0k3r.n3t - Des news sur votre site grace à phpBB</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Language" content="fr" />
<link rel="StyleSheet" type="text/css" href="style.css" />
</head>
<div id="conteneur">      
   <h1 id="header">
      <a href="http://www.j0k3r.net" onclick="window.open(this.href);return(false);"><img src="http://www.j0k3r.net/img/jok/logo_jok_big.jpg" alt="" style="border: 0px;" /></a>
   </h1>
   <div id="contenu">
<?
//Initialisation de la variable "qui compte les news"
$j = 1;
while($data = mysql_fetch_array($req))
{
    //Affichage du titre
    echo '<h2>'.$data['topic_title'].'</h2>';
    //On parse la news pour y interprété le BBcode
    $message = bbencode_second_pass($data['post_text'], $data['bbcode_uid']);
    $message = str_replace("\n\r", "\n", $message);
    $message = str_replace("\n", "<br />\n", $message);
    //On s'occupe des smileys
    $req_smilies = mysql_query("SELECT * FROM `".$table_prefix."smilies`");
    $k = 0;
    while($data_smilies = mysql_fetch_array($req_smilies))
    {
        $smilies[$k]['code'] = $data_smilies['code'];
        $smilies[$k]['smile_url'] = $data_smilies['smile_url'];
        $smilies[$k]['emoticon'] = $data_smilies['emoticon'];
        $k ++;
    }
    if (count($smilies))
    {
        usort($smilies, 'smiley_sort');
    }
    for ($i = 0; $i < count($smilies); $i++)
    {
        $orig[] = "/(?<=.\W|\W.|^\W)".phpbb_preg_quote($smilies[$i]['code'], "/")."(?=.\W|\W.|\W$)/";
        $repl[] = '<img src="'.$phpbb_root_path.'images/smiles/'.$smilies[$i]['smile_url'].'" alt="'.$smilies[$i]['emoticon'].'" />';
    }
    $message = preg_replace($orig, $repl, ' '.$message.' ');
    $message = substr($message, 1, -1);
    //Affichage du contenu de la news
    echo '<p>'.$message.'</p>';
    //Affichage de l'auteur
    echo '<h3>Posté par <a href="'.$phpbb_root_path;
    echo 'profile.php?mode=viewprofile&amp;u='.$data['user_id'].'">'.$data['username'].'</a>';
    //De l'heure
    echo ' le '.date('d/m/y à H:i', $data['topic_time']).' - ';
    //Des commentaires
    echo '<a href="'.$phpbb_root_path.'viewtopic.php?t=';
    echo $data['topic_id'].'">['.$data['topic_replies'].'] commentaire(s)</a></h3>';
    //Si on atteinds 5 news, on arrete
    if($j >= 5)
    {
        break;
    }
    $j++;
}
?>
   </div>
</div>
<p id="footer">
   <a href="http://www.j0k3r.net" onclick="window.open(this.href);return(false);">j0k3r_n0ir</a> © 2005
</p>
</body>
</html>
Title: Re: Include php files, into the template
Post by: Sami on July 02, 2006, 10:10:45 PM
ok, you want this file to be a part of your cpg theme or you wnat just a link to this file?
- if you want to show info on your cpg then you should try anycontent.php , put your code (without header and footer) to anycontent.php and active it , see:
http://coppermine-gallery.net/demo/cpg14x/docs/index.htm#admin_album_list
- if you need only a link to this file then add

<a href="{froum_info_url}">{link_title}</a>


to template.html and then add {forum_info_url} & {link_title} to theme.php as described before
Title: Re: Include php files, into the template
Post by: tyio on July 02, 2006, 10:26:28 PM
yes, my aim is to show the script into the page ;)

EDIT :

ok, i have the same error :


Fatal error: Cannot redeclare make_clickable() (previously declared in /var/alternc/html/t/tyio/include/functions.inc.php:539) in /var/alternc/html/t/tyio/phpBB2/includes/bbcode.php on line 617

arf ;(( ^^
Title: Re: Include php files, into the template
Post by: Sami on July 03, 2006, 05:26:44 AM
remove "include_once($phpbb_root_path.'includes/bbcode.php');"
from anycontent.php and check it