Welcome to Geeklog Saturday, September 21 2019 @ 01:51 pm EDT

Geeklog Forums

new theme using CSS-P


Status: offline

machinari

Forum User
Full Member
Registered: 22/03/04
Posts: 1512
Well, there it is... My latest contribution to the war on tables.
It's called purplerose and you can get it here.

similar layout to the clean theme that ships with GL, but no tables except for where tabular data is displayed and in plugins. Let me know what you think and/or where and on what it breaks. See it in action at http://shadee.summitpages.ca if you want a preview fullsize.

Make sure you read the readme for important notes about minor core changes.

Status: offline

Dirk

Site Admin
Admin
Registered: 12/01/02
Posts: 13073
Location:Stuttgart, Germany
Quote by machinari: Make sure you read the readme for important notes about minor core changes.

Ignoring the other changes outlined in the Readme for the moment, your main issue seems to be passing a flag from index.php through to your theme's version of COM_siteHeader. So in other words, all you need to know here is if your on index.php or on some other page?

If so, it should be possible to figure that out in your version of COM_siteHeader, too, so that the theme could work without that code change.

Just an idea (and of course it doesn't help with the hard-coded width="100%" tables ...).

bye, Dirk

Status: offline

machinari

Forum User
Full Member
Registered: 22/03/04
Posts: 1512
Quote by Dirk:your main issue seems to be passing a flag from index.php through to your theme's version of COM_siteHeader. So in other words, all you need to know here is if your on index.php or on some other page?

If so, it should be possible to figure that out in your version of COM_siteHeader, too, so that the theme could work without that code change.

That's an excellent idea. I never thought of that--obviously.
thanks Dirk!

Status: offline

machinari

Forum User
Full Member
Registered: 22/03/04
Posts: 1512
here you go peeps. now you can make this theme work without changing the GL core.

Replace the custom Com_siteHeader, found in the theme's function.php with this version of it:
PHP Formatted Code
function purplerose_siteHeader( $what = 'menu' )
{
    global $_CONF, $_USER, $LANG01, $_COM_VERBOSE, $topic, $LANG_BUTTONS, $LANG_CHARSET;
    global $_TABLES, $HTTP_POST_VARS, $HTTP_GET_VARS;

    $header = new Template( $_CONF['path_layout'] );
    $header->set_file( array(
        'header'        => 'header.thtml',
        'menuitem'      => 'menuitem.thtml',
        'menuitem_last' => 'menuitem_last.thtml',
        'menuitem_none' => 'menuitem_none.thtml',
        'leftblocks'    => 'leftblocks.thtml',
        'rightblocks'   => 'rightblocks.thtml'
        ));

    $pagetitle = '';
    if( isset( $_CONF['pagetitle'] ))
    {
        $pagetitle = $_CONF['pagetitle'];
    }
    if( empty( $pagetitle ))
    {
        $pagetitle = $_CONF['site_slogan'];
    }
    if( !empty( $pagetitle ))
    {
        $pagetitle = ' - ' . $pagetitle;
    }
    $header->set_var( 'page_title', $_CONF['site_name'] . $pagetitle );

    //quickfix for table-laden plugins not cooperating with CSS-P.
    //add your plugin dir to the $plugins array.
    $plugins = array(forum, faqman, staticpages, stats, ewiki, filemgmt, menu,);
    $clicked = $_SERVER['REQUEST_URI'];
    $plugin_fix = '';
    foreach ($plugins as $val) {
        if (eregi($val, $clicked)) {
            $plugin_fix = "<table cellspacing="0" cellpadding="0" border="0"><tr><td class="forumfix">";
        }
    }
    $header->set_var( 'plugin_fix', $plugin_fix );
    //end quickfix for table-laden plugins breaking this theme

    $header->set_var( 'background_image', $_CONF['layout_url'] . '/images/bg.gif' );
    $header->set_var( 'site_url', $_CONF['site_url'] );
    $header->set_var( 'layout_url', $_CONF['layout_url'] );
    $header->set_var( 'site_mail', "mailto:{$_CONF['site_mail']}" );
    $header->set_var( 'site_name', $_CONF['site_name'] );
    $header->set_var( 'site_slogan', $_CONF['site_slogan'] );
    $rdf = substr_replace( $_CONF['rdf_file'], $_CONF['site_url'], 0,
                           strlen( $_CONF['path_html'] ) - 1 );
    $header->set_var( 'rdf_file', $rdf );
    $header->set_var( 'rss_url', $rdf );

    $msg = $LANG01[67] . ' ' . $_CONF['site_name'];

    if( !empty( $_USER['username'] ))
    {
        $msg .= ', ' . $_USER['username'];
    }

    $curtime =  COM_getUserDateTimeFormat();

    $header->set_var( 'welcome_msg', $msg );
    $header->set_var( 'datetime', $curtime[0] );
    $header->set_var( 'site_logo', $_CONF['layout_url'] . '/images/logo.gif' );
    $header->set_var( 'css_url', $_CONF['layout_url'] . '/style.css' );
    $header->set_var( 'theme', $_CONF['theme'] );

    if( empty( $LANG_CHARSET ))
    {
        $charset = $_CONF['default_charset'];

        if( empty( $charset ))
        {
            $charset = "iso-8859-1";
        }
    }
    else
    {
        $charset = $LANG_CHARSET;
    }

    $header->set_var( 'charset', $charset );

    // Now add variables for buttons like e.g. those used by the Yahoo theme
    $header->set_var( 'button_home', $LANG_BUTTONS[1] );
    $header->set_var( 'button_contact', $LANG_BUTTONS[2] );
    $header->set_var( 'button_contribute', $LANG_BUTTONS[3] );
    $header->set_var( 'button_links', $LANG_BUTTONS[4] );
    $header->set_var( 'button_polls', $LANG_BUTTONS[5] );
    $header->set_var( 'button_calendar', $LANG_BUTTONS[6] );
    $header->set_var( 'button_sitestats', $LANG_BUTTONS[7] );
    $header->set_var( 'button_personalize', $LANG_BUTTONS[8] );
    $header->set_var( 'button_search', $LANG_BUTTONS[9] );
    $header->set_var( 'button_advsearch', $LANG_BUTTONS[10] );

    // Now add nested template for menu items

    // contribute link
    if( empty( $topic ))
    {
        $contributelink = $_CONF['site_url'] . '/submit.php?type=story';
        $header->set_var( 'current_topic', '' );
    }
    else
    {
        $contributelink = $_CONF['site_url']
                        . '/submit.php?type=story&topic=' . $topic;
        $header->set_var( 'current_topic', '&topic=' . $topic );
    }

    $allowedCounter = 0;
    $header->set_var( 'menuitem_url', $contributelink );
    $header->set_var( 'menuitem_text', $LANG01[71] );
    $header->parse( 'menu_elements', 'menuitem', true );
    if(( isset( $_USER['uid'] ) && ( $_USER['uid'] > 1 )) ||
        (( $_CONF['loginrequired'] == 0 ) && ( $_CONF['submitloginrequired'] == 0 )))
    {
        $header->parse( 'allowed_menu_elements', 'menuitem', true );
        $allowedCounter++;
    }

    // links link
    $header->set_var( 'menuitem_url', $_CONF['site_url'] . '/links.php' );
    $header->set_var( 'menuitem_text', $LANG01[72] );
    $header->parse( 'menu_elements', 'menuitem', true );
    if(( isset( $_USER['uid'] ) && ( $_USER['uid'] > 1 )) ||
        (( $_CONF['loginrequired'] == 0 ) && ( $_CONF['linksloginrequired'] == 0 )))
    {
        $header->parse( 'allowed_menu_elements', 'menuitem', true );
        $allowedCounter++;
    }

    // polls link
    $header->set_var( 'menuitem_url', $_CONF['site_url'] . '/pollbooth.php' );
    $header->set_var( 'menuitem_text', $LANG01[73] );
    $header->parse( 'menu_elements', 'menuitem', true );
    if(( isset( $_USER['uid'] ) && ( $_USER['uid'] > 1 )) ||
        (( $_CONF['loginrequired'] == 0 ) && ( $_CONF['pollsloginrequired'] == 0 )))
    {
        $header->parse( 'allowed_menu_elements', 'menuitem', true );
        $allowedCounter++;
    }

    // calendar link
    $header->set_var( 'menuitem_url', $_CONF['site_url'] . '/calendar.php' );
    $header->set_var( 'menuitem_text', $LANG01[74] );
    $header->parse( 'menu_elements', 'menuitem', true );
    if(( isset( $_USER['uid'] ) && ( $_USER['uid'] > 1 )) ||
        (( $_CONF['loginrequired'] == 0 ) && ( $_CONF['calendarloginrequired'] == 0 )))
    {
        $header->parse( 'allowed_menu_elements', 'menuitem', true );
        $allowedCounter++;
    }

    // Get plugin menu options
    $plugin_menu = PLG_getMenuItems();

    if( $_COM_VERBOSE )
    {
        COM_errorLog( 'num plugin menu items in header = ' . count( $plugin_menu ), 1 );
    }

    if( count( $plugin_menu ) == 0 )
    {
        $header->parse( 'plg_menu_elements', 'menuitem_none', true );
    }
    else
    {
        for( $i = 1; $i <= count( $plugin_menu ); $i++ )
        {
            $header->set_var( 'menuitem_url', current( $plugin_menu ));
            $header->set_var( 'menuitem_text', key( $plugin_menu ));

            if( $i == count( $plugin_menu ))
            {
                $header->parse( 'plg_menu_elements', 'menuitem_last', true );
            }
            else
            {
                $header->parse( 'plg_menu_elements', 'menuitem', true );
            }

            next( $plugin_menu );
        }
    }

    // Search link
    $header->set_var( 'menuitem_url', $_CONF['site_url'] . '/search.php' );
    $header->set_var( 'menuitem_text', $LANG01[75] );
    $header->parse( 'menu_elements', 'menuitem', true );
    if(( isset( $_USER['uid'] ) && ( $_USER['uid'] > 1 )) ||
        (( $_CONF['loginrequired'] == 0 ) && ( $_CONF['searchloginrequired'] == 0 )))
    {
        $header->parse( 'allowed_menu_elements', 'menuitem', true );
        $allowedCounter++;
    }

    // Stats link
    $header->set_var( 'menuitem_url', $_CONF['site_url'] . '/stats.php' );
    $header->set_var( 'menuitem_text', $LANG01[76] );
    $header->parse( 'menu_elements', 'menuitem_last', true );
    if(( isset( $_USER['uid'] ) && ( $_USER['uid'] > 1 )) ||
        (( $_CONF['loginrequired'] == 0 ) && ( $_CONF['statsloginrequired'] == 0 )))
    {
        $header->parse( 'allowed_menu_elements', 'menuitem', true );
        $allowedCounter++;
    }

    if( $allowedCounter == 0 )
    {
        $header->set_var( 'allowed_menu_elements', '' );
    }

    if( $what <> 'none' )
    {
        // Now show any blocks -- need to get the topic if not on home page
        if( !isset( $HTTP_GET_VARS['topic'] ))
        {
            if( isset( $HTTP_GET_VARS['story'] ))
            {
                $sid = COM_applyFilter( $HTTP_GET_VARS['story'] );
            }
            elseif( isset( $HTTP_GET_VARS['sid'] ))
            {
                $sid = COM_applyFilter( $HTTP_GET_VARS['sid'] );
            }
            elseif( isset( $HTTP_POST_VARS['story'] ))
            {
                $sid = COM_applyFilter( $HTTP_POST_VARS['story'] );
            }
            if( !empty( $sid ))
            {
                $topic = DB_getItem( $_TABLES['stories'], 'tid', "sid='$sid'" );
            }
        }
        else
        {
            $topic = COM_applyFilter( $HTTP_GET_VARS['topic'] );
        }
        $header->set_var( 'geeklog_blocks', COM_showBlocks( 'left', $topic ));
        $header->parse( 'left_blocks', 'leftblocks', true );
    }
    else
    {
        $header->set_var( 'geeklog_blocks', '' );
        $header->set_var( 'left_blocks', '' );
    }
   
    //call the right blocks
    $clicked = "http://";
    $clicked .= $_SERVER['HTTP_HOST'];
    $clicked .= $_SERVER['REQUEST_URI'];
    $siteurl = $_CONF['site_url']."/";
    $address = array($_CONF['site_url'].'/index.php', 'otherPagesFromWhichToLoadRightBlocks',);
        //default vars
    $header->set_var( 'geeklog_blocks', '' );
    $header->set_var( 'right_blocks', '' );
        //loads rightblocks if site url is called.
    if (( $siteurl != '') && ( $siteurl == $clicked )){
        $rightblock = true;
        if( $rightblock ) {
            $rblocks = COM_showBlocks( 'right', $topic );
        }
        if( $rightblock && !empty( $rblocks )) {
            $header->set_var( 'geeklog_blocks', $rblocks );
            $header->parse( 'right_blocks', 'rightblocks', true);
        }
        else {
            $header->set_var( 'geeklog_blocks', '' );
            $header->set_var( 'right_blocks', '' );
        }
    }
        //loads rightblocks if array address is called
    elseif (!empty( $address )){
        $rightblock = true;
        foreach ($address as $val){
            if (eregi($val, $clicked)) {
                if( $rightblock ) {
                    $rblocks = COM_showBlocks( 'right', $topic );
                }
                if( $rightblock && !empty( $rblocks )) {
                    $header->set_var( 'geeklog_blocks', $rblocks );
                    $header->parse( 'right_blocks', 'rightblocks', true);
                }
                else {
                    $header->set_var( 'geeklog_blocks', '' );
                    $header->set_var( 'right_blocks', '' );
                }
            }
        }
    }
   
    // Call any plugin that may want to include Extra Metatags or Javascript functions
    $header->set_var( 'plg_headercode', PLG_getHeaderCode());

    // The following line allows users to embed PHP in their templates.  This
    // is almost a contradition to the reasons for using templates but this may
    // prove useful at times...don't use PHP in templates if you can live without it

    $tmp = $header->parse( 'index_header', 'header' );

    ob_start();
    eval( '?>' . $tmp );
    $retval = ob_get_contents();
    ob_end_clean();

    return $retval;
}

 

All changes to the core as outlined in the readme are no longer necessary, so don't change the core. Right blocks will load from the custom Com_siteHeader. thanks again Dirk.

here is an updated readme as well.
PHP Formatted Code
"purplerose" theme by machinari and SummitPages.ca

3 column theme based on the clean theme layout, but using CSS-P, and it works.

This theme was designed to look similar to one of the default GL themes
    (clean--except for color) in order to illustrate that these layouts
    are not impossible for CSS-P.
   
95% of the template files are built from scratch  (plugins not included)
    and so, after about 5000 page refreshes, it's done!  Many tables were
    injured/killed in the making of this theme.  Tabular data remains tabled,
    however some presentation remains in those particular files cuz I got tired.
   

features include:

    *   Tableless layout using CSS-P.  Tables used only to display tabular data or
        to accomodate functions with hardcoded table elements as well as plugins.
       
    *   All style relegated to the style sheet--again, except where it is hardcoded
        into the core functions or plugins.  --not quite finished this yet.
       
    *   A nested right column giving the appearance of an expanding center column
        whenever the right blocks are not called.
            *   The ONLY way to accomplish the expanding center column (using CSS-P)
                is to load the right blocks from the header and call them before the
                center column in order to have them float right.
            *   The floated rightblocks allow the center column, when it extends
                below the right blocks or when the right blocks are not called, to
                extend to the right margin.  This applies to the left blocks as well.
               
    *   Transparent story blocks revealing a fixed position background image (if
        you choose to have a background image there is code prepared for you in
        the style sheet--uncomment it to see it in action).
       
    *   Tested in Moz 6, IE 6, Opera 6--all on a windows machine.  Feel free to let
        me know if it breaks otherwise and your suggestions for a fix.  In fact please
        do test in other browsers and post your findings at geeklog.net.


**--IMPORTANT NOTES and NOTES ON INSTALLATION--**

    1   If you choose not to use the image for the not-featured story bottom
        border, then I suggest you uncomment the "div.notfeatured {borderstuff: stuff;}"
        in the style sheet, cuz without borders the story blocks may look a bit confusing.
        The borders will keep your head on straight.  :P
       
    2   ****Note:  In fixing the plugins, this issue is also fixed as long as "stats" remains in the array--see note 5.
        Had to remove the hardcoded table width=100% from the plugins'
function.inc,
        specifically from the plugin_showstats_pluginname($showsitestats) function,
        to deal with the stats page (no longer necessary--see note 5).
        For example, here are the details for the forum's function.inc and the staticpages'
        funtion.inc file:
            in path/to/geeklog/plugins/forum/function.inc, change
                    $retval = "<table border = '0' width='100%' cellspacing='0' cellpadding='0'>";
                    $retval .= "<tr><td>$summary_label</td>";
            to
                    $retval = "<table border = '0' cellspacing='0' cellpadding='0'>";
                    $retval .= "<tr><td width='100%'>$summary_label</td>";
            (You can find that in "function plugin_showstats_forum($showsitestats)")
            and in path/to/geeklog/plugins/staticpages/function.inc, change
                    $retval = '<table border="0" width="100%" cellspacing="0" cellpadding="0">';
                    $retval .= '<tr><td>' . $LANG_STATIC['staticpages'] . '</td>';
            to
                    $retval = '<table border="0" cellspacing="0" cellpadding="0">';
                    $retval .= '<tr><td width="100%">' . $LANG_STATIC['staticpages'] . '</td>';
            (You can find that in "function plugin_showstats_staticpages($showsitestats)")
        ****Note:  In fixing the plugins, this issue is also fixed as long as "stats" remains in the array--see note 5.
           
    3   Forms look ugly when they wrap column 1, so to avoid this you can just set
        margin-left: 167px; or thereabouts, on the col2 content that you don't want
        to wrap left, eg, stats and forms.  If you change how the columns are set up
        and load, then you'
ll have to adjust this margin accordingly.
       
    4   Once all the HTML is removed from the GL core, this theme will break in many
        places due to its accomodation of that hard-coded HTML.
       
    5   For the table-laden plugins, which break the theme now, I have provided a
        quick and dirty fix...
            *   Coded into the custom Com_siteHeader and Com_siteFooter is a bit of
                code that will, upon advancing to a plugin page, load that page inside
                one big table cell with width set to 1% thereby accomodating all
                the tables with width set to 100%, which breaks this CSS-P theme.
                Check the code to add applicable plugin dirs to the array.  These
                functions are found in purplerose/functions.php.
       
    6   Oh, and if you want to see an example of a bloated style sheet--here ya go!
        In my defense, I did it for your benefit.  :P
        The style sheet is quite messy so feel free to clean it up--I will be as time
        goes on.
       
 

Status: offline

NeoNecro

Forum User
Regular Poster
Registered: 07/02/04
Posts: 90
Hey,
I'm also making a theme which only uses div tags, but it looks like the Com_siteHeader function is changed a bit. Can you guys provide me with an updated one? Or is this not needed?

grtz
dimis-site.be

mach

Anonymous
not sure what you are asking for... the COM_siteHeader in lib-custom.php? or the custom function in this particular theme? if the later, then you can download the latest version of the purplerose theme at summitpages.ca. The custom COM_siteHeader is located in the functions.php file.

It is not yet 1.3.10 compliant, btw.

Status: offline

NeoNecro

Forum User
Regular Poster
Registered: 07/02/04
Posts: 90
Quote by mach:
It is not yet 1.3.10 compliant, btw.

It's that what I'm asking for. I'm looking for the COM_siteHeader that I can use with 1.3.10.
Sorry if I wasn't very clear.
dimis-site.be

Status: offline

caltman

Forum User
Junior
Registered: 12/07/04
Posts: 25
I am using this theme on two sites. It does work with 1.3.10rc1 if you copy a couple of template files (archivestorysomethiingorother.thtml) from another theme. You might find what you are looking for by reviewing the COM_siteheader function in the functions.inc file for this theme.

Regards,
Carter

All times are EDT. The time is now 01:51 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content