Jump to content

Search the Community

Showing results for tags 'news managment'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 1 result

  1. Today I tried to create a News feed, and I think it became pretty good! But there is one problem, I have marked it in the code - so if anyone have a clue, tell me! This one requires two template; news.root (title) and news.article(title, body, summary, news_tags[comma separated values], images[optional]). CSS: .news-item .news-image{ width:250px; border:1px solid #CCC; text-align:center; vertical-align:middle; padding-top:2px; display:block; } .news-item .news-summary{ width:auto; } .news-item .news-image p{ padding:1px; margin:0px !important; text-align:center !important; } .news-item .news-read-more{ text-align:right; } .news-item .news-read-more a{ color:#373737 !important; } .news-item .news-read-more a:hover{ background:none !important; text-decoration:underline !important; } .news-item{ border-bottom:.4px dashed #CCC; } .news-item p{ text-align:left; } .news-pager { clear: both; margin: 1em 0; font-family: Arial, sans-serif; } .news-pager li { display: inline; list-style: none !important; list-style-type:none !important; margin: 0; } .news-pager li a, .news-pager li.separator { display: block; float: left; padding: 2px 9px; color: #fff; background: #2f4248; margin-right: 3px; font-size: 10px; font-weight: bold; text-transform: uppercase; } .news-pager li.active a, .news-pager li a:hover { color: #fff; background: #db1174; text-decoration: none; } .news-pager li.separator { display: inline; color: #777; background: #d2e4ea; padding-left: 3px; padding-right: 3px; } the news.root.php template <?php include("./head.inc"); /** * News template, the base part! * * By Max Allan Niklasson */ $tagQuery = $sanitizer->text($input->get->tag); $label = (object) array( 'altTag' => 'Bild', 'postedUnder' => 'Postad under', 'readMore' => 'Läs mer »»', 'published' => 'Publicerad den', 'by' => 'av', 'prev' => 'Föregående', 'next' => 'Nästa', 'tagExpl' => 'Filtrering av nyheter med taggen: <em>'.$tagQuery.'</em>, visar %s träff(ar) av %s träff(ar). <br/> <a href="'.$page->url().'">Visa alla nyheter</a>' ); /** Here I have one issue when set limit = 1, the pager don't work... Solution? **/ $limit = 3; //To fix the pager $start = ($sanitizer->text($input->get->page) ? $limit * $sanitizer->text($input->get->page) - $limit : 0); function thumbGet(Page $page, $label){ if($page->images){ $image = $page->images->first(); if($image){ if($image->width() > 250){ $thumb = $image->size(250); }elseif($image->height() > 250){ $thumb = $image->size(0, 250); }else{ $thumb = $image; } $return = "\n\t\t\t\t\t\t\t\t". '<div class="news-image">'. "\n\t\t\t\t\t\t\t\t\t". '<img src="'.$thumb->url().'" alt="'.$label->altTag.'" />'. "\n\t\t\t\t\t\t\t\t\t". '<p>'.$image->get('description').'</p>'. "\n\t\t\t\t\t\t\t\t". '</div>'; return $return; }else{return false;} } else{ return false; } } function processNewsItem(Page $news, $label, Users $users){ $writer = $news->createdUser; $tags = split(',',$news->news_tags); echo "\n\t\t\t\t\t".'<div class="news-item">'; echo "\n\t\t\t\t\t\t".'<h2>'.$news->title.'</h2>'; echo "\n\t\t\t\t\t\t\t".'<p>'; echo "\n\t\t\t\t\t\t\t\t".'<div class="news-summary">'.$news->summary.'</div>'; if(thumbGet($news, $label)){ echo thumbGet($news, $label); } echo "\n\t\t\t\t\t\t\t".'</p>'; if($tags[0]){ echo "\n\t\t\t\t\t\t\t". "<div class='news-info'>"; echo $label->postedUnder.": "; $tagCount = 0; foreach($tags as $tag){ if($tagCount != 0) {echo ' | ';} echo "\n\t\t\t\t\t\t\t\t". '<a href="?tag='.$tag.'">'.$tag.'</a>'; $tagCount++; } echo "\n\t\t\t\t\t\t\t\t". '<div class="news-published">'.$label->published.': '.date("Y-m-d \k\l\. H:i:s", $news->created).' '. $label->by .' '.$writer->name.'</div>'; echo "\n\t\t\t\t\t\t\t". '</div>'; } echo "\n\t\t\t\t\t\t\t".'<div class="news-read-more">'. "\n\t\t\t\t\t\t\t\t".'<a href="'.$news->url.'">'.$label->readMore.'</a>'. "\n\t\t\t\t\t\t\t".'</div>'; echo "\n\n\t\t\t\t\t".'</div> <!-- news-item -->'; } function pagination(PageArray $cPages, PageArray $tPages, $label, $limit, $sanitizer, $input){ //The URL fix $URL = ($sanitizer->text($input->get->tag) ? '?tag='.$sanitizer->text($input->get->tag).'&page=#NR#' : '?page=#NR#'); //Calculate number of matches that should be viewing $calc = $cPages->count(); //The Totally number of pages $tot = $tPages->count(); $pages = round(($tot / $limit) + 1); if($tot <= $limit){ }else{ echo '<ul class="news-pager">'; if($pages <= $sanitizer->text($input->get->page) && 0 < ($sanitizer->text($input->get->page) -1) ){ echo '<li><a href="'.str_replace('#NR#', ($sanitizer->text($input->get->page)-1), $URL).'">'.$label->prev.'</a>'; } for($i = 1; $i <= $pages; $i++){ $class = ''; if($sanitizer->text($input->get->page) == $i){ $class = 'class="active"'; }elseif($sanitizer->text($input->get->page) == 0 && $i == 1){ $class = 'class="active"'; } echo '<li '. $class .'><a href="'.str_replace('#NR#', $i, $URL).'">'.$i.'</a>'; } if($pages >= $sanitizer->text($input->get->page) && $pages >= ($sanitizer->text($input->get->page) +1) ){ echo '<li><a href="'.str_replace('#NR#', ($sanitizer->text($input->get->page)+1), $URL).'">'.$label->next.'</a>'; } echo '</ul>'; } } ###### Let's Print it out! ####### /** The viewer from tag query **/ if($tagQuery){ $counter = $page->children('template=news.article, news_tags*='.$tagQuery.', sort=-date, sort=-id '); $newsItems = $page->children('template=news.article, news_tags*='.$tagQuery.', sort=-date, sort=-id, start='.$start.', limit='.$limit); if($newsItems->count()) { printf($label->tagExpl, $newsItems->count(), $counter->count() ); echo "\t\t\t\t".'<div class="news-list">'; foreach($newsItems as $news){ processNewsItem($news, $label, $users); } echo "\n\n\t\t\t\t".'</div><!-- news-list -->'; } }else{ /** The Normal News viewer **/ $counter = $page->children('template=news.article'); $newsItems = $page->children('template=news.article, sort=-date, sort=-id, start='.$start.', limit='.$limit); if($newsItems->count()) { echo "\t\t\t\t".'<div class="news-list">'; foreach($newsItems as $news){ processNewsItem($news, $label, $users); } echo "\n\n\t\t\t\t".'</div><!-- news-list -->'; } } pagination($newsItems, $counter, $label, $limit, $sanitizer, $input); include("./foot.inc"); But there is one thing that I wonder about, is it necessary to attach ($label, $sanitizer, $input etc.) in the function? When I tried global but it didn't work...
×
×
  • Create New...