It looks like you're new here. If you want to get involved, click one of these buttons!
http://docs.getfuelcms.com/general/pages-variables#news
and want to plug into my first page but I got some questions:
<?php
$slug = uri_segment(2);
if (!empty($slug))
{
$news_item = fuel_model('news', array('find' => 'one', 'where' => array('slug' => $slug)));
if (empty($news_item)) show_404();
}
else
{
$news = fuel_model('news');
}
?>
<?php if (!empty($news_item)) : ?>
<?php fuel_set_var('page_title', $news_item->headline); ?>
<blockquote class="blockquote-red">
<p><i class="glyphicon glyphicon-calendar"></i> <?=$news_item->release_date_formatted?></p>
<p><?=$news_item->content_formatted?></p>
</blockquote>
<?php else: ?>
<?php foreach($news as $item) : ?>
<blockquote class="blockquote-red">
<p><i class="glyphicon glyphicon-calendar"></i> <?=$item->release_date_formatted?></p>
<p><?=$item->get_excerpt_formatted(200, 'Read more »')?></p>
</blockquote>
<?php endforeach; ?>
<?php endif; ?>
<h4 class="heading-red">Latest News</h4>
{$load->view('news')}
Comments
$varrs['language'] = $CI->fuel->language->detect();
I'd recommend reading the following documentations about the Language class and how you can
http://docs.getfuelcms.com/general/localization
http://docs.getfuelcms.com/libraries/fuel_language
2. You'll need to add it as a where parameter in your query (see #3)
3.
$news = fuel_model('news', array('limit' => 2, 'language' => $language));
Let me study and try!
Many thanks.
1/ Added the following to the fuel/application/views/_variables/global.php file.
$vars['language'] = $CI->fuel->language->detect();
View file:
<?php $slug = uri_segment(2); if (!empty($slug)) { $news_item = fuel_model('news', array('find' => 'one', 'where' => array('slug' => $slug, 'language' => $language))); if (empty($news_item)) show_404(); } else { $news = fuel_model('news', array('limit' => 2, 'where' => array ('language' => $language), 'order' => 'release_date desc')); } ?> <?php if (!empty($news_item)) : ?> <?php fuel_set_var('page_title', $news_item->headline); ?> <blockquote class="blockquote-red"> <p><i class="glyphicon glyphicon-calendar"></i> <?=$news_item->release_date_formatted?></p> <p><?=$news_item->content_formatted?></p> </blockquote> <?php else: ?> <?php foreach($news as $item) : ?> <blockquote class="blockquote-red"> <p><i class="glyphicon glyphicon-calendar"></i> <?=$item->release_date_formatted?></p> <p><?=$item->get_excerpt_formatted(200, 'Read more »')?></p> </blockquote> <?php endforeach; ?> <?php endif; ?>