Welcome to Geeklog Tuesday, July 16 2019 @ 04:17 am EDT

Geeklog Forums

Home page to the style Joomla


Status: offline

usarfans

Forum User
Junior
Registered: 10/08/03
Posts: 34
cordiste provided a wonderful and easy to implement solution for two columns on the main page. It's working well for me as too but I have one question. Can the code be modified so that the chronology of the articles displayed is changed? With cordiste's code, the left column takes the first 5 stories based on date, after the feature story, and puts them in the left column. It then goes back to the to top and the right column and puts the remaining articles. They are arranged like this:
PHP Formatted Code

Left              Right
April 10        April 5
April 9         April 4
April 8         April 3
April 7         April 2
April 6         April 1
 
It looks nice but I was wondering if a change could be made to have the articles alternate left -- right -- left -- right, etc. based on date of the article so the most recent are always on top of other articles. Like this:
PHP Formatted Code

Left              Right
April 10        April 9
April 8         April 7
April 6         April 5
April 4         April 3
April 2         April 1
 
Does this make sense? I did my best to look at the code and see if I could do it myself, but quite frankly, I'm just not smart enough! Thanks for any thoughts on the matter. Lou

Status: offline

::Ben

Forum User
Full Member
Registered: 14/01/05
Posts: 1569
Location:la rochelle, France
Hello,

@KunfuBeer

Counts were here to test, it is cleaner to remove them on a productive site Wink

@usarfans

Are you looking for something like this one?

PHP Formatted Code

    // get remaining stories
       
        $storycount = 2;
       
    while ($A = DB_fetchArray ($result)) {
        $story = new Story();
        $story->loadFromArray($A);
                if (($storycount) % 2 == 0)
        {
           $display .= '<div id="columnleft" style="float:left; width:48%;padding-right:10px;">';
                   $display .= STORY_renderArticle ($story, 'y');
                   $display .= '</div>';
        }
           else
        {
           $display .= '<div id="columnright" style="float:right; width:48%;padding-right:10px;">';
                   $display .= STORY_renderArticle ($story, 'y');
                   $display .= '</div>';
                   // Comment out this next line if you do not need horizontal alignment 2 stories by 2
                   $display .= '<div style="clear:both"></div>';
        }
                $storycount ++;
                 

    }        
        $display .= '<div style="clear:both"></div>';
                       
    // get plugin center blocks that follow articles


::Ben
I'm available to customise your themes or plugins for your Geeklog CMS

Status: offline

usarfans

Forum User
Junior
Registered: 10/08/03
Posts: 34
Quote by: cordiste

@usarfans

Are you looking for something like this one?
::Ben



I'll try it out tonight and let you know! Thanks for the very fast reply!

Lou

Status: offline

Dirk

Site Admin
Admin
Registered: 12/01/02
Posts: 13073
Location:Stuttgart, Germany
Just curious: Has anyone tried using the {story_counter} variable? It's increased for every story (0 for the featured story, 1 for the first, 2 for the second, and so on). I was wondering if you could use something like class="story{story_counter}" (and CSS classes like story0, story1, etc.) to produce a two-column layout without any actual code changes?

bye, Dirk

Status: offline

::Ben

Forum User
Full Member
Registered: 14/01/05
Posts: 1569
Location:la rochelle, France
Yes it is working Smile

This is storytext.thtml
PHP Formatted Code

<div class="story{story_counter}">
    <span class="story-icons">
        {email_icon}
        {print_icon}
        {pdf_icon}
        {edit_icon}
    </span>
    <h1>{story_title_link}</h1>
    <div class="story-information">
        <p>{story_date}</p>
        <p>{lang_contributed_by} {start_contributedby_anchortag}{contributedby_author}{end_contributedby_anchortag}</p>
        <p>{lang_views} {story_hits}</p>
    </div>
    <div class="story-body">
        {story_anchortag_and_image}{story_text_no_br}
    </div>
    <div class="story-footer">
        <p>{page_selector}</p>
        <p>{readmore_link} {post_comment_link}</p>
        <p>{plugin_itemdisplay}{comments_with_count} {trackbacks_with_count}</p>
    </div>
</div>


and new classes in style.css

PHP Formatted Code

.story3 , .story5, .story7, .story9, .story11, .story13, .story15{
  float:left;
  width:48%;
  padding:10px 10px 10px 0px;
  background:transparent;
  color:#000000;
}
.story2, .story4, .story6, .story8, .story10, .story12, .story14, .story16{
  float:left;
  width:48%;
  padding:10px 10px 10px 0px;
  background:transparent;
  color:#000000;
}


If you wish to add content after the stories make a staticpage starting with

PHP Formatted Code
<div style="clear:both;"></div>


::Ben
I'm available to customise your themes or plugins for your Geeklog CMS

Status: offline

::Ben

Forum User
Full Member
Registered: 14/01/05
Posts: 1569
Location:la rochelle, France
And if you need three columns

PHP Formatted Code

.story3 , .story5, .story7, .story9, .story11, .story13, .story15, .story2, .story4, .story6, .story8, .story10, .story12, .story14, .story16{
  float:left;
  width:31%;
  padding:10px 15px 10px 0px;
  background:transparent;
  color:#000000;
}
 


::Ben
I'm available to customise your themes or plugins for your Geeklog CMS

Status: offline

usarfans

Forum User
Junior
Registered: 10/08/03
Posts: 34
cordiste,

The code you provided to reorder the two columns chronology worked well. Thank you!

I did make two minor changes. The first one was to comment out the line that lined up the top of the stories. For my site it caused too much blank white space for my taste.

The second change added an extra <br> after the articles and before the plugin centerblocks, mostly just for my personal preference.

Thanks again. I have not tried the optional method of using story1, story2, etc. Didn't want to push my luck with editing two files :-)

Lou

All times are EDT. The time is now 04:17 am.

  • 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