Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [ADDON] showArticles  (Read 803 times)

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
[ADDON] showArticles
« on: February 12, 2012, 08:28:32 PM »

Hi all,
Here is a function to display articles and pages sepereted from center function
( was requested by adminphp here for v1.6 ).

This function should work for v1.7.,
Display as meny articles or pages and a mix of them as well.
Can be called as meny times and location on your template.
Includs Read more link.


Install:
1. Copy this function to your snews.php
Code: [Select]
<?php
function showArticles($art1){
global $categorySEF;
$num sizeof($art1);
if($num<1){die('No parameters for the showArticles() function !!!');}
$union='';
foreach($art1 as $k => $v){
if($k>0){
$union .= " union (select * from "._PRE."articles where title = '$v' limit 1)";
}
}
$qry "(select * from "._PRE."articles where title = '$art1[0]' limit 1) $union";
$res mysql_query($qry) or die(mysql_error());
while($r mysql_fetch_array($res)){
$title ucfirst($r['title']);
$seftitle $r['seftitle'];
$date $r['date'];

if($r['category']){
$postCat cat_rel($r['category'], 'seftitle');
$postCat $postCat.'/';
} else {
$postCat '';
}

$text stripslashes($r['text']);
if ($categorySEF=='') {$short_display strpos($text'[break]'); 
$shorten $short_display == 9999000 $short_display;} 
else { $shorten 9999000; }
echo '<div class="wbox">';
echo '<div class="ttlbox">';
echo '<h3><a href="'._SITE.$postCat.$seftitle.'/" title="'.l('read_more').' - '.$title.'"><strong>'.$title.'</strong></a></h3> ';
echo '<span class="adate">'.l('on').' | '.$date.'</span>';
echo '</div>';
echo '<div class="artbox">';
file_include(str_replace('[break]''',str_replace('&''&amp;'$text)), $shorten);
echo '</div>';
echo '<div class="bck"><a href="'._SITE.$postCat.$seftitle.'/" title="'.l('read_more').' - '.$title.'">'.l('read_more').'</a></div>';
echo '<div class="clearer"> </div>';
echo '</div>';
}
}
?>



2. Copy this code to your template ( index.php ):
    Use: The $art_Arr variable is an array, inside there are titles for the articles wanted.
           Copy the TITLE for the page or article to the array, seperet more then one with a comma (,)
            'article1 title', 'article2 title', 'page title' etc.... minimum one.

Code: [Select]
<?php
if ($categorySEF=='') {
$art_Arr = array( 'php section','Welcome to sNews 1.7 MUMTCS''moding front page bla bla');
showArticles($art_Arr);
}
?>


3. Copy this styles to the head section on your index file, or to the css file ( without the style ) tags:
Code: [Select]
<style type="text/css">
.wbox{margin:5px 0 10px 0; width:200px;}
.ttlbox h3 {font-size:16px; margin:0px 0; padding:0;}
.adate{font-size:11px; margin:0px 0; padding:0;}
.artbox{margin:0px 0 0 10px;font-size:12px;}
.bck{margin:4px 0;}
</style>



Awesome evening
 8)
« Last Edit: February 14, 2012, 06:45:58 AM by mosh »
Logged

scept1c

  • Newbie
  • *
  • Karma: 0
  • Posts: 1
    • TheFactory.ro
Re: [ADDON] showArticles
« Reply #1 on: March 13, 2012, 03:15:35 PM »

cool, thx