TinyPortal

Development => Support => Topic started by: GhostRider2110 on October 01, 2014, 01:51:54 AM

Title: Format articles in a catagory into two columns?
Post by: GhostRider2110 on October 01, 2014, 01:51:54 AM

Link to my forum: http://www.usscalemasters.org/forum/ (http://www.usscalemasters.org/forum/)
SMF version: SMF ver. 2.0.8
TP version: TP ver. 1.1.0.7
Default Forum Language: English
Theme name and version: Modified BigSky

Not really a problem, but can this be accomplished. I have a block on the front page, "2014 Championship Announcements"
It is an upper panel block, defined as articles in a category.  Is there any way to format them in to columns?

As shown in the attached screen shot, they are in one column.  Would be neater if they could be lined up in 2
columns.

Thanks for any help..

See-ya
Mitch
Title: Re: Format articles in a catagory into two columns?
Post by: IchBin on October 02, 2014, 01:17:24 AM
I believe the  TPortal_categorybox() is the function you are looking for in Themes/default/TPsubs.template.php. I think that function handles the layout for the category and articles listings for that block type. 

Something like this should not create a new line unless there are two items. Then it puts in the break tag.  If you want it to look different you'll just have to add some bits into the echo statement where the HTML parts are.
function TPortal_categorybox()
{
    global $context, $txt, $scripturl;

if(isset($context['TPortal']['blockarticle_titles'][$context['TPortal']['blocklisting']])){
echo '<div class="middletext" ', (sizeof($context['TPortal']['blockarticle_titles'][$context['TPortal']['blocklisting']])>$context['TPortal']['blocklisting_height'] && $context['TPortal']['blocklisting_height']!='0') ? ' style="overflow: auto; width: 100%; height: '.$context['TPortal']['blocklisting_height'].'em;"' : '' ,'>';
$count = 1;
foreach($context['TPortal']['blockarticle_titles'][$context['TPortal']['blocklisting']] as $listing){
if($listing['category'] == $context['TPortal']['blocklisting'])
echo '<b><a href="'.$scripturl.'?page='.$listing['shortname'].'">'.$listing['subject'].'</a></b> ' , $context['TPortal']['blocklisting_author']=='1' ? $txt['by'].' '.$listing['poster'] : '';
if ($count % 2 == 0) {
echo '<br />';
}
$count++;
}
echo '</div>';
}
}


Gives you something to work with anyway. :) Just remember if you change this code in this file, any upgrade or file refresh will wipe out your changes.
Title: Re: Format articles in a catagory into two columns?
Post by: GhostRider2110 on October 02, 2014, 02:14:06 AM
Thanks Ich, that helps.  Here is the code I added:

// category listing blocktype
function TPortal_categorybox()
{
    global $context, $txt, $scripturl;

        if(isset($context['TPortal']['blockarticle_titles'][$context['TPortal']['blocklisting']])){
                echo '<div class="middletext" ', (sizeof($context['TPortal']['blockarticle_titles'][$context['TPortal']['blocklisting']])>$context['TPortal']['blocklisting_heig
ht'] && $context['TPortal']['blocklisting_height']!='0') ? ' style="overflow: auto; width: 100%; height: '.$context['TPortal']['blocklisting_height'].'em;"' : '' ,'>';
                $count = 1;
                foreach($context['TPortal']['blockarticle_titles'][$context['TPortal']['blocklisting']] as $listing){
                        if($listing['category'] == $context['TPortal']['blocklisting'])
                                echo '<b><a href="'.$scripturl.'?page='.$listing['shortname'].'">'.$listing['subject'].'</a></b> ' , $context['TPortal']['blocklisting_author']=
='1' ? $txt['by'].' '.$listing['poster'] : '';
                if ($count % 2 == 0) {
                        echo '<br />';
                } else {
                        echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                }
                $count++;
                }
                echo '</div>';
        }
}


Is better attached is how it looks now.  Would be nice to be able to event the columns out.  Will play with it, any suggestions appreciated.

--Mitch
Title: Re: Format articles in a catagory into two columns?
Post by: GhostRider2110 on October 02, 2014, 02:24:17 AM
Hmmm the code I added messes up any left or right panel block.  Anyway to check to see which panel it is going in then determine if to use the different formatting?  --Mitch
Title: Re: Format articles in a catagory into two columns?
Post by: IchBin on October 02, 2014, 06:12:50 AM
Off the top of my head, I'm unsure if which panel is available in the code somewhere so you can check that.

Might be able to do something like this to make the layout work.
http://blog.andyhume.net/responsive-containers/
Title: Re: Format articles in a catagory into two columns?
Post by: GhostRider2110 on October 02, 2014, 06:39:31 PM
Thanks, I'll play around with it some.. if you or anyone else thinks of something else, I would appreciate it...

See-ya
Mitch