A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Perhaps you all could be of some assistance

  1. #1
    Junior Member
    Join Date
    Jun 2002
    Posts
    5

    Perhaps you all could be of some assistance

    This isn't really flash related, but you guys seem to know EVERYTHING, so I figured I'd come here and ask this.

    I'm in the process of creating a new layout for my comic strip's website. My goal is to have multiple themes and they would all just follow the same basic layout, buuuut with different pictures and themes.

    For example-One of the themes would be an X-man theme, and there'd be a picture of the X-man character on the top of the page.

    Then there'd be....say a Gilligans Island theme(Not really) and then there'd be a picture of Gilligan on the top.

    Same pic sizes, same layout, just different colors and pictures.

    I thought about having a dropdown box that would have values and then through php it would take that value, and make it into a variable like "$id". Then I could just name all of the pictures like 1,2,3 etc. base on each theme, and print it like <img blah blah ?<?php$1?>main.jpg. You know?

    Now, this is difficult. If anyone has any ideas or easier methods, please tell me.

    The PHP variable would also work for a CSS clip that would change the colors of like the DIV layers.

    Please help if you can or lead me to someone who could. Thank you.

  2. #2
    I would use smarty.

    http://smarty.php.net
    http://smarty.php.net/crashcourse.php


    Each theme would then have its own template file or files.

    Basicly, you would share the varables you assigned to smarty.


    PHP Code:
    <?
    include('lib/Smarty.class.php');
    $smarty = new Smarty;

    if(!$theme){
    theme = "default";
    };

    //assign varables used in the templates
    $smarty->assign('comic', 'today.jpg');
    $smarty->assign('title', '--Todays Comic--');

    $smarty->display($theme."htm");
    Your default.htm
    .. could look something like this:


    PHP Code:
    <html>
    <
    head><title>My Comic - {$title}</title></head>
    <
    body>
    {
    $title} <br>
    <
    img src='{$comic}'>
    </
    body>
    </
    html
    nice and powerful
    If you wanted to theme many pages you would want to use directorys to hole the themes rather then the file names, as haveing them all mixed together would a a headache.

    This is also vary close to how forums theme.

    *edit* fixed bug in code
    Avataur (Flash) Graphical Chat
    www.avataur.com

  3. #3
    AS a bit of a demo of what you can do with smarty - i do something some what similar on my site www.avatuar.com

    Though its not really user settable, its made so i can switch themes dearing seasons and such.

    PHP Code:
    <?
    //Config.php
    define('SMARTY', '/home/avataur/www.avataur.com/libs/Smarty.class.php');
    define('TEMPATE_BASE',"/home/avataur/www.avataur.com/templates/");

    define('CACHE',"/home/avataur/www.avataur.com/cache");
    define('TEMPATE_C',"/home/avataur/www.avataur.com/templates_c");
    define('CONFIGS',"/home/avataur/www.avataur.com/configs");

    if(!$template){
            $template = "av20";
    }

    define('TEMPLATE',TEMPATE_BASE . $template);

    // smarty.php
    require(SMARTY);
    $smarty = new Smarty;
    $smarty->template_dir = TEMPLATE;
    $smarty->compile_dir = TEMPATE_C;
    $smarty->config_dir = CONFIGS;
    $smarty->cache_dir = CACHE;

    $smarty->cache_lifetime = 3600;
    $smarty->caching = 2;
    // $smarty->compile_check = true;
    if($debug){
    $smarty->debugging = true;
    }

    function smarty_block_dynamic($param, $content, &$smarty) {
        return $content;
    }
    $smarty->register_block('dynamic', 'smarty_block_dynamic', false);


    // index.php
    include config.php;
    include smarty.php;

    $smarty->template_dir = TEMPLATE . "/" . "home";
    if(!$smarty->is_cached("main.htm","avataur_index")){
    // Build page!

    //
    //$smarty->debugging = true;
    $smarty->assign("template",$template);
    //$smarty->assign("main","news.htm");
    $smarty->assign("compile_date",date("F j, Y, g:i a"));
    }

    $smarty->display("main.htm","avataur_index");
    You can ignore all the defines, i set them because this will be acessed from a number of directorys.


    main.htm:
    PHP Code:
    <HTML>
    <
    HEAD>
    <
    TITLE>. : A V A T A U R : . . . Graphical Chat Role Play</TITLE>
    <
    META content="text/html; charset=windows-1252" http-equiv=Content-Type>
    {
    literal}
    <
    STYLE>A:link {
        
    COLOR#cbdcf3; FONT-WEIGHT: bold; TEXT-DECORATION: none
    }
    A:visited {
        
    COLOR#cbdcf3; FONT-WEIGHT: bold; TEXT-DECORATION: none
    }
    A:active {
        
    COLOR#cbdcf3; FONT-WEIGHT: bold; TEXT-DECORATION: none
    }
    A:hover {
        
    COLOR#caffe3; FONT-WEIGHT: bold; TEXT-DECORATION: underline
    }
    .
    overlaytop {
        
    background-imageurl(avataur_files/overlay2.png);
        
    filteralpha(Opacity=70);
        
    color#FFFFFF;
        
    font-weightbold;
        
    font-size16px;
        
    font-familyVerdanaArialHelveticasans-serif;
        
    letter-spacing5px;
        
    text-indent25pt;
    }
    .
    overlaylower {
        
    background-imageurl(avataur_files/overlay1.png);
        
    filteralpha(Opacity=80);
        
    color#FFFFFF;
        
    text-indent5pt;
    }
    .
    text2 {
        
    color#FFFFFF;
    }
    </
    STYLE>
    {/
    literal}
    <
    META content="MSHTML 5.00.3502.5390" name=GENERATOR>
    </
    HEAD>
    <
    BODY aLink=#cccccc bgColor=#475d7b bottomMargin=50 leftMargin=0 link=#cccccc 
    rightMargin=0 text=#cbdcf3 topMargin=40 vLink=#cccccc>
    <TABLE border=0 cellPadding=0 cellSpacing=0 height="100%" width="100%">
      <
    TBODY>
      <
    TR>
        <
    TD>
          <
    CENTER>
              <
    IMG src="images/av20/welcometitle.jpg"
              <
    TABLE width=749 height=479 border=0 cellPadding=0 cellSpacing=0 background="{if !$main}images/av20/welcomeimage.jpg{else}images/av20/welcomeimage1.jpg{/if}">
                <
    TBODY>
                  <
    TR vAlign=top
                    <
    TD width="21"></TD>
                    <
    TD width="240">{include file='menu.htm'}<BR>
                      <
    br>
                      <
    BR>
                      {
    dynamic}
                      &
    nbsp; &nbsp; &nbsp; &nbsp; &nbspOnline users: {include file="/home/avataur/www.avataur.com/online_count.txt"}<br>
                      <
    br>
                      {/
    dynamic}
                      </
    font> </TD>
                    <
    TD width="488" valign="top">{if $main != ""}{include file="$main"}{/if} 
                    </
    TD>
                  </
    TR>
                </
    TBODY>
              </
    TABLE>
            </
    CENTER></TD></TR></TBODY></TABLE>
            {
    literal}
    <
    SCRIPT>

    var 
    message = new Array() // leave this as is

    message[0] = "A V A T A U R";

    var 
    reps 1

    var speed 150

    // DO NOT EDIT BELOW THIS LINE.
    // ============================
    var p=message.length;
    var 
    T="";
    var 
    C=0;
    var 
    mC=0;
    var 
    s=0;
    var 
    sT=null;
    if(
    reps<1)reps=1;
    function 
    doTheThing(){
    T=message[mC];
    A();}
    function 
    A(){
    s++
    if(
    s>8){s=1}
    // you can fiddle with the patterns here...
    if(s==1){document.title='|o----| '+T+' |----o|'}
    if(
    s==2){document.title='|-o---| '+T+' |---o-|'}
    if(
    s==3){document.title='|--o--| '+T+' |--o--|'}
    if(
    s==4){document.title='|---o-| '+T+' |-o---|'}
    if(
    s==5){document.title='|----o| '+T+' |o----|'}
    if(
    s==6){document.title='|---o-| '+T+' |-o---|'}
    if(
    s==7){document.title='|--o--| '+T+' |--o--|'}
    if(
    s==8){document.title='|-o---| '+T+' |---o-|'}
    if(
    C<(8*reps)){
    sT=setTimeout("A()",speed);
    C++
    }else{
    C=0;
    s=0;
    mC++
    if(
    mC>p-1)mC=0;
    sT=null;
    doTheThing();}}
    doTheThing();

    </
    SCRIPT>
    {/
    literal} <br>
    <
    table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
      <
    tr>
        <
    td><div align="center"><font size="2">Page last compiled on: {$compile_date}</font></div></td>
      </
    tr>
    </
    table>
    </
    BODY></HTML
    neat little trick, this template file is called on a by about 5 diffent pages.

    If i set $main .. to another filename, the background is automaticly switched to a watermarking, allowing me to reuse this bit of code over and over
    Last edited by ZorTiger; 09-09-2004 at 10:42 AM.
    Avataur (Flash) Graphical Chat
    www.avataur.com

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center