Results 1 to 6 of 6

Thread: Customize header template in V3.1 ?

  1. #1
    Join Date
    Aug 2002
    Location
    Germany
    Posts
    1,180

    Default Customize header template in V3.1 ?

    ai,

    next question

    I want to use new headers (standart and cat), that shows a top bar and a left bar.

    So I need the follow fields and functines in the header and I don't know where I should do this:

    <%cat%> to add the a new link with using the header (or perhaps the footer ! and to search in the category with the search bar.

    -> hot links will only work, if it is used in index-template.

    -> Do I need somethink special to show "Who is online", "Statistics" and "tell a friend" in the header ?

    With this I can put the complete left part of the site into the header and this is much easier to show this part on all sites !

    Hm, it is a difficult question - then I think about this I want to use more fields in the header, like a special Page-Title for the detail-template or some more things.

    If I want to show more fields (also custom fields) in the header, what should I do ?

    Hope someone can help

    Greetings
    Frank
    Last edited by Frank71; 04-23-2003 at 06:18 AM.

  2. #2
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

    Default

    In template programming, you should first tell php which variables will be replaced. You need to assign/connect php variable and template variable. Since it is fixed and hard coded, you must change codes if you want to move template variable from 'content' file to 'header' file.

    With indexu you can assign using this command:
    PHP Code:
    DisplayTemplate($theme_path."index.html",
    "\$category,\$new_links,\$hot_links,\$login_box,".
    "\$rec_links,\$recomended_listing,".
    "\$total_online,\$members_online,\$guess_online,\$username_online,".
    "\$total_link,\$total_hits,\$total_category,\$total_member,\$total_milis"); 
    The above example you found in index.php, in case you want to use header, just cange index.html to header.html

    But if you want display "Who is online" and "Statistics" in all pages using header.html, it does not as simple as above example. You need to copy/paste php code that generate result / calculate for "Who is online" and "Statistics". It may not so difficult, just copy line 200-230 to other files.

    You also need to make those variables as global
    PHP Code:
    global $total_online$members_online$guess_online$username_online;
    global 
    $total_link$total_hits$total_category$total_member$total_milis 

  3. #3
    Join Date
    Aug 2002
    Location
    Germany
    Posts
    1,180

    Default

    Originally posted by dody
    In template programming, you should first tell php which variables will be replaced. You need to assign/connect php variable and template variable. Since it is fixed and hard coded, you must change codes if you want to move template variable from 'content' file to 'header' file.

    With indexu you can assign using this command:
    DisplayTemplate($theme_path."index.html",
    "\$category,\$new_links,\$hot_links,\$login_box,". ....
    "\$rec_links,\$recomended_listing,".
    "\$total_online,\$members_online,\$guess_online,\$ username_online,".
    "\$total_link,\$total_hits,\$total_category,\$tota l_member,\$total_milis");
    The above example you found in index.php, in case you want to use header, just cange index.html to header.html


    Gretat, now I understand the system !


    But if you want display "Who is online" and "Statistics" in all pages using header.html, it does not as simple as above example. You need to copy/paste php code that generate result / calculate for "Who is online" and "Statistics". It may not so difficult, just copy line 200-230 to other files.

    You also need to make those variables as global
    global $total_online, $members_online, $guess_online, $username_online;
    global $total_link, $total_hits, $total_category, $total_member, $total_milis
    Ok, I have only the beat here in office, but I found this in the index:
    // ---------------
    // functions
    // ---------------
    function ShowMainPage() {
    // vars global configuration
    global $conn, $dbServer, $dbHostname, $dbUsername, $dbPassword, $dbName, $theme_path,$number_of_links_format, $cat_default_image, $cat_columns, $main_new_links, $main_hot_links, $max_sub_cat, $cat_font_face, $cat_font_size, $cat_link_style, $subcat_font_face, $subcat_font_size, $subcat_link_style, $cat_table_width, $cat_cellspacing,
    $cache_time,$use_cache_status,$theme_name, $recomended_listing, $cat_description_format, $COOKIE_USERNAME, $total_online, $members_online, $guess_online, $username_online;
    // vars messages
    global $msg;
    // vars template
    global $category,$new_links,$hot_links,$login_box, $rec_links,$recomended_listing;

    This means all these variables are global and can be used in all templates, if I use the Display templade order ?
    By example "total online" and "main hot links" are global and I have to add the rest of the variables I ant to sho an other pages, yes ?

    Perhaps if you have some more time you can write a list of all variables which are used by the script

    Greetings
    Frank

  4. #4
    Join Date
    Aug 2002
    Location
    Germany
    Posts
    1,180

    Default doesn't work

    Hello Dody,

    I tested to show the hot_links also in the header of the index, but it doesn't work !

    I used this for the template:
    DisplayTemplate($theme_path."header.html","\$title ,\$cat,\$hot_links");

    But this doesn't work - I can see them in the index template, but also in the header template I see nothing
    The script seems to read the variable because I can't see it in the source code, but nothing else happen

    Frank

  5. #5
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

    Default

    Well indexu must have forced you to learn php harder ...

    This is why your header doesn't work. It's php behavior (and other programming too). You seem there's variable scope. Let see at glance file index.php.

    include (...)
    .....
    function ShowMainPage() {
    ...
    }

    ...
    DisplayTemplate($theme_path."header.html","\$title ,\$cat");
    ShowMainPage();
    DisplayTemplate($theme_path."footer.html","\$cat") ;

    You know why $hot_links doesn't work? Because it's out of variable scope. $hot_links is inside function ShowMainPage() and can't reach by

    DisplayTemplate($theme_path."header.html","\$title ,\$cat,\$hot_links");

    that reside out from function ShowMainPage(). So you should put displaytemplate in function ShowMainPage().

    include (...)
    .....
    function ShowMainPage() {
    ...
    ...

    DisplayTemplate($theme_path."header.html","\$title ,\$cat,\$hot_links");
    DisplayTemplate($theme_path."index.html",
    "\$category,\$new_links, ..........
    DisplayTemplate($theme_path."footer.html","\$cat") ;
    }

    ...
    ShowMainPage();

  6. #6
    Join Date
    Aug 2002
    Location
    Germany
    Posts
    1,180

    Unhappy hmpf

    ai,

    ok, now it works on my index and I can show what I want in the header and footer - bad that I forget, that new, top, hot usw. uses the same header-template....

    See my post here:
    http://www.nicecoder.com/community/s...&threadid=1371

    I want universal header and footer - all script information in header (top and left) and footer (right and bottom).

    Is it not possible to add a universal code in an external file and include it into all files ?

    Greetings
    Frank

Similar Threads

  1. switch to smarty template engine
    By dody in forum v5.x
    Replies: 20
    Last Post: 01-10-2005, 04:58 PM
  2. Undestanding templates
    By dody in forum Tutorials, Hints & Tips
    Replies: 2
    Last Post: 01-04-2004, 03:37 AM
  3. Replies: 2
    Last Post: 08-05-2003, 02:16 AM
  4. Customize style sheets in V3.1 ?
    By Frank71 in forum Templates
    Replies: 4
    Last Post: 04-25-2003, 04:46 PM
  5. Replies: 6
    Last Post: 11-11-2002, 02:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •