Blog posts from category isn't displayed - php

I've created a page and then put this code
<section class="cont_pad">
<div class="container_12">
<article class="grid_8">
{{ blog:posts limit="5" offset="5" category="adultos" }}
<section class="post">
{{ if imagen_portada }}
<div class="postimg"><img src="{{ url:site }}files/thumb/{{ imagen_portada.id }}/610/220" class="pic2" alt="{{title}}" title="{{title}}"/></div>
{{ endif }}
<div class="entry-date">
<div class="posttime">
<h3>{{ helper:date timestamp=created_on }}</h3>
</div>
<div class="entry-utility">
{{ asset:image file="blog/icon1.png" }} {{ user:display_name user_id=author_id }}
<br/>
{{ if category }}
<span>{{ asset:image file="blog/icon2.png" }} {{ category:title }}</span>
{{ endif }}
{{ if keywords }}
<span>{{ asset:image file="blog/icon2.png" }} {{ keyword }}</span>
{{ endif }}
</div>
</div>
<div class="entry-text">
<h3 class="posttitle">{{ title }}</h3>
<div class="entry-content">
{{ intro }}
<p>{{ helper:lang line="blog:read_more_label" }}</p>
</div>
</div>
</section>
{{ /blog:posts }}
{{ pagination }}
</article>
<article class="grid_4 last-col">
<aside id="sidebar">
{{ widgets:area slug="widgets_blog_adultos" }}
</aside>
</article>
</div>
</section>
inside to show posts from category "adultos" but I'm not getting nothing. I have one post and it's LIVE in this category. What is wrong? I read Blog Plugin Docs also check the Blog Plugin Code at package "PyroCMS\Core\Modules\Blog\Plugins" and can't find where it fails. Also and related to this same question, can I paginate trough all the posts? I need some help here because I can't find what is wrong

Is the timezone on the computer set up wrong? If PyroCMS thinks the "Publish Date" is in the future it wont show it on the frontend.

Related

How can i have the form text empty?

I dont know the way to leave the the form text empty is there is no result.I need something like this.....
If there is no userCreator = form text empty
My code
<div class="col-md-4">
<div class="form-group">
{{ Form::label('userCreator','UserCreator') }}
#if(isset($userCreator))
#foreach($userCreator as $cs)
{{ Form::text('userCreator',$cs->home_lastname,['class'=>'form-control']) }}
#endforeach
#else{ {{-- What should i put inside here ? --}}
}
#endif
</div>
</div>
#if(isset($userCreator) && count($userCreator) > 0)
<div class="col-md-4">
<div class="form-group">
{{ Form::label('userCreator','UserCreator') }}
#foreach($userCreator as $cs)
{{ Form::text('userCreator',$cs->home_lastname,['class'=>'form-control']) }}
#endforeach
</div>
</div>
#endif
try this ...
<div class="col-md-4">
<div class="form-group">
{{ Form::label('userCreator','UserCreator') }}
#if(!empty($userCreator))
#foreach($userCreator as $cs)
{{ Form::text('userCreator',$cs->home_lastname,['class'=>'form-control']) }}
#endforeach
#else
{{ Form::text('userCreator','', ['class'=>'form-control']) }}
#endif
</div>
</div>

Different default template loading even though i have set routing correctly

In my views folder i have layouts/main.blade.php and under store/index.blade.php i am using the layout file like so:
#extends('layouts.main') // importing here.
#section('promo')
<section id="promo">
<div id="promo-details">
<h1>Today's Deals</h1>
<p>Checkout this section of<br/>
products at a discounted price.</p>
Shop Now
</div><!-- end promo-details -->
{{ HTML::image('img/promo.png' , 'Promotional Ad') }}
</section><!-- promo -->
#stop
#section('content')
<h2>New Products</h2>
<hr>
<div id="products">
#foreach($products as $product)
<div class="product">
<a href="store/view/{{ $product->id }}">
{{ HTML::image($product->image , $product->title , array('class'=>'feature' ,
'width'=>'240' , 'height'=>'127')) }}
</a>
<h3>
<a href="/store/view/{{ $product->id }}">
{{ $product->title }}
</a>
</h3>
<p>
{{ $product->description }}
</p>
<h5>Availability:
<span class="{{ Availability::displayClass($product->availability) }}">
{{ Availability::display($product->availability) }}
</span>
</h5>
<p>
<a href="#" class="cart-btn">
<span class="price">${{ $product->price }}</span>
{{ HTML::image('img/white-cart.gif' , 'Add to Cart') }}
ADD TO CART
</a>
</p>
</div>
#endforeach
</div> <!-- end products -->
#stop
In my storeController , i am calling the store/index.blade.php file like so:
public function getIndex() {
return View::make('store.index')
->with('products' , Product::take(4)->orderBy('created_at' , 'DESC')->get());
}
In my routing file, i have the following:
Route::get('/', array('uses' => 'StoreController#getIndex'));
But still when i load my / , i get some other template rather than layouts/main.blade.php. Why is this happening ? can anybody explain ?
Why is layouts/main.blade.php not loading when i hit / in the browser ?
Thank you.
Alex-z.
Well i had the following syntax .
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
{{ HTML::style('css/bootstrap.css') }}
{{ HTML::style('css/animate.min.css') }}
{{ HTML::style('css/style.css') }}
{{ HTML::style('css/nprogress.css') }}
{{ HTML::style('css/new-arrivals.css') }}
Removing the below line
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
solved my problem ... Why though ? also how do i disable cache in laravel during development ?

Laravel Commenting System Only Working on most recent Post

I recently created a commenting system for a blog. When there is one post in the blog, the commenting sytem works fine. However, when there are two posts on the blog, and I comment on the FIRST post, the comment shows up on the SECOND post. Similarily, if I add another post, so there are three posts in my blog, when I comment on the first post, the comment shows up under the third post. In the same situation, when I comment on the second post, the comment shows up under the third post. Here is my code:
/index.blade.php
#section('content')
<div class="col-md-8 col-md-offset-2">
<hr>
#foreach($posts as $post)
<h3>{{ $post->title}}</h3>
<p>by {{ $post->user->name }}</p>
<img src='{{ asset($post->image_path) }}' class="img-responsive" id="blogpic"/>
<p>{{ Str::words($post->body) }}</p>
<p>Read More...</p>
<hr>
{{ Form::open(array('action' => 'CommentController#newComment')) }}
{{ Form::hidden('post_id', $post->id) }}
<div class="row">
<div class="col-md-10">
{{ Form::text('body', null, array('class'=>'form-control')) }}
</div>
<div class="col-md-2">
{{ Form::submit('Post', array('class'=>'btn btn-info')) }}
</div>
</div>
<br>
#foreach($post->comments as $comment)
<div class="comment">
<p><span class="bold">{{ $comment->user->name }}</span>: {{ $comment->body }}</p>
</div>
#endforeach
#endforeach
</div>
#stop
Here is my new comment controller:
public function newComment()
{
$comment = New Comment();
$comment->user_id = Auth::user()->id;
$comment->post_id = $post_id = Input::get('post_id');
$comment->body = Input::get('body');
Post::find($post_id)->comments()->save($comment);
return Redirect::action('BlogController#index');
}
I am pretty sure the problem is in my index file, and I can provide more code if needed. My comment only seems to get the most recent id in this line
{{ Form::hidden('post_id', $post->id) }}
What could be going wrong?
Thanks in advance

Display RSS feed with Laravel PHP using SimpleXML

I want to display a RSS feed, keeping it as simple as possible.
I am using Laravel 4.
Here is my controller :
public function getHome()
{
$content = file_get_contents('http://rss.leparisien.fr/leparisien/rss/paris-75.xml');
$flux = new SimpleXmlElement($content);
return View::make('frontend/homepage', compact('flux'));
}
And here is my view :
#foreach ($flux as $flu)
<article class="entry-item">
<img src="{{utf8_decode((string)$flu->item->enclosure['url'])}}" alt="">
<div class="entry-content">
{{ $flu->item->title }}
{{ $flu->item->description }}
</div>
</article>
#endforeach
This is working fine, but only one article (item) is shown.
I tried to find a way to get several items displayed with SimpleXMLElement::attributes
I can't find any clear tutorial about it.
try this
#foreach ($flux[0]->item->link as $item)
<article class="entry-item">
<img src="{{utf8_decode((string)$item->enclosure['url'])}}" alt="">
<div class="entry-content">
{{ $item->title }}
{{ $item->description }}
</div>
</article>
#endforeach
because you have mutliple items
#foreach ($flux->channel->item as $flu)
<article class="entry-item">
<img src="{{utf8_decode((string)$flu->enclosure['url'])}}" alt="">
<div class="entry-content">
{{ $flu->title }}
{{ $flu->description }}
</div>
</article>
#endforeach

pyrocms assign count to variable

I would like to check if is last post from loop. I am using pyroCMS. But problem is that if i am using helper:count two times it is not working correctly. How can i assign helper:count to variable and use later variable. Is this possible?
{{ blog:posts limit="5" order-by="title" order-dir="desc" }}
{{ if { helper:count mode="subtract" } == blog:all_posts}}
<li>
<a href="{{ url }}" title="Read more about: {{ title }}">
<span class="naslovna_datum_novice">{{ helper:date format="d.m.Y" timestamp=created_on }} - </span>
{{ title }}
</a>
</li>
{{ elseif { helper:count mode="subtract" } == 5 }}
<li>
<a href="{{ url }}" title="Read more about: {{ title }}">
<span class="naslovna_datum_novice">{{ helper:date format="d.m.Y" timestamp=created_on }} - </span>
{{ title }}
</a>
</li>
{{ else }}
<li class="pikce_spodaj">
<p>
<a href="{{ url }}" title="Read more about: {{ title }}">
<span class="naslovna_datum_novice">{{ helper:date format="d.m.Y" timestamp=created_on }} - </span>
{{ title }}
</a>
</p>
</li>
{{ endif }}
{{ /blog:posts }}
So how to assign {{ helper:count mode="subtract" }} to variable?? How to assign anything to variable?
There's actually a simpler way; the streams core code adds a last property to the final item in an array - source code - that you can just query with a conditional:
{{ if last }} foo {{ endif }}
(The source code that does that is
Here's a working example for blogs I've just tested:
{{ blog:posts limit="5" order_by="title" }}
<h2>{{ title }}</h2>
[...]
{{ if last }}<p>This is the last item</p>{{ endif }}
{{ /blog:posts }}
Also, as Nick points out, you can have more than one counter.

Categories