Ultimate goal; two columns on front page which show the two categories side by side.
Present changes; This was an involved process that was constructed with several separate coding processes.
Two css files were altered;
- style.css has been adjusted with a new leftcoltwo and stories_two value, allowing the pages to fit together.
templates/oioioi/pligg.tpl was altered with the following code, to create a loop that constructed as many columns as categories.
{if $pagename eq "submit"}
{elseif $pagename eq "index" } if index page
{section name=thecat loop=$cat_array start=$start} starts a loop; one loop for each catagory
[div id="leftcoltwo"] uses the leftcoltwo values for thinner columns
{if $pagename eq "group_story"}
[div id="group_navbar"][/div]
{/if}
{checkActionsTpl location="tpl_pligg_content_start"}
{checkActionsTpl location="tpl_pligg_above_center"}
{include file="wistie/index_center_index.tpl"}
{checkActionsTpl location="tpl_pligg_below_center"}
{checkActionsTpl location="tpl_pligg_content_end"}
[/div]
{/section}
A series of if-else loops were added to index_center.tpl to connect to different link summary output functions to link to different link_summery.tpl files
{if $cat_array[thecat].name eq 'News'}
{$news_link_summary_output}
{else}
{if $cat_array[thecat].name eq 'Opinion'}
{$opinion_link_summary_output}
{else}
{$link_summary_output}
{/if}
{/if}
From here, I had to modify libs/link_summary.php, libs/link.php and templates/oioioi/link_summery.tpl to individualize the index page columns without altering the rest of the site.
I added new functions to libs/link_summary.php to call separate functions from libs/link.php
$news_link_summary_output .= $link-> print_news_summary('summary', true);
$opinion_link_summary_output .= $link-> print_opinion_summary('summary', true);
and added control functions to allow feedback from the index.php file
if(isset($fetch_news_link_summary) && $fetch_news_link_summary == true){
$main_smarty->assign('news_link_summary_output', $news_link_summary_output);
} else {
echo $news_link_summary_output;
}
if(isset($fetch_opinion_link_summary) && $fetch_opinion_link_summary == true){
$main_smarty->assign('opinion_link_summary_output', $opinion_link_summary_output);
} else {
echo $opinion_link_summary_output;
}
In libs/link.php I copied the function print_summary which calls templates/oioioi/link_summery.tpl. These were;
print_news_summary altered to link to link_summary_news.tpl
print_opinion_summary altered to link to link_summary_opinion.tpl
To allow feedback from index.php, I had to adding new code
$fetch_news_link_summary = true;
$fetch_opinion_link_summary = true;
Finally, two copies of templates/oioioi/link_summery.tpl were created; link_summary_opinion.tpl and link_summary_news.tpl. These two new files had if-else loops added at the start of the file and the div class was changed to stories_two for the thinner columns;
{if $link_category eq "News"} Inserted code that activates if link_category is News
This resulted in three files;
link_summary.tpl -standard
link_summary_news.tpl -news only
link_summary_opinion.tpl -opinion only
No comments:
Post a Comment