PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Jul 25, 2017 5:31 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Nov 17, 2016 5:53 pm 
Offline
Forum Contributor
User avatar

Joined: Wed May 14, 2014 12:18 pm
Posts: 320
I think i have asked this question before , but somehow i have still now been able to achieve or solve this , hence i will ask again:

I want three boxes on my home page in my bolt-cms and when clicked on these 3 boxes i would like that whatever that box category is , a new page opens with only the articles related to that particular category .... now i have't yet been able to figure how exactly this would work , i mean i have the idea in my mind , but just can't get it to join togeather , so i know that the below line of code:

Syntax: [ Download ] [ Hide ]
{% setcontent travelpages = 'pages' where { categories: 'travel' } %}


Will give me only all the articles related to travel ... and the below line code:

Syntax: [ Download ] [ Hide ]
{% setcontent codingpages = 'pages' where { categories: 'coding' } %}


will only give me all the categories related to coding ....

now , I suppose i would have a template that looks like the below:

Syntax: [ Download ] [ Hide ]
{% setcontent records = 'pages' where { categories: $categories } %}
                   
                    {% for record in records  %}
                        <div class="col-md-4">
                            <figure class="hm-page-blog-post-preview">

                                {# <img src="{{ thumbnail(record.image|image, 200, 200)  }}" alt=""> #}
                               {# <img src="{{ thumbnail(record.image|image, 200, 200)  }}" alt=""> #}
                               <img src="{{ record.image|image }}" alt="">

                                <figcaption>
                                    {# DIFF:: What is popup and what does the below line do  #}
                                   {# {{ popup(record.image, 1200, 500) }} #}
                                   <h2><a href="{{ record.link }}">{{ record.title }}</a></h2>
                                    {% if record.introduction %}
                                        {{ record.introduction }}
                                    {% elseif record.teaser %}
                                        {{ record.teaser }}
                                    {% else %}
                                        <p>{{ record.excerpt(300, false, search|default('')) }}</p>
                                    {% endif %}
                                </figcaption>

                            </figure>


                        </div>

                    {% else %}
                        <article>

                            <h2>{{ __('general.phrase.no-content-found') }}</h2>

                            <p>
                                {{ __("Unfortunately, no content could be found. Try another page, or go to the <a href=\"%paths_root%\">homepage</a>.", {'%paths_root%': paths.root} ) }}
                            </p>

                        </article>
                    {% endfor %}
 


Check the 1st line of code:

Syntax: [ Download ] [ Hide ]
{% setcontent records = 'pages' where { categories: $categories } %}



The variable

Syntax: [ Download ] [ Hide ]
$categories


is what gets passed from the previous template as the particular category ... but how do i exactly pass the variable from the main template ??

I believe the 3 boxs on the home page will be <a> tags , and but what exactly do i add in the href ???

I hope what i'am saying makes sense . Basically what i want is what is what do i add in the href of the <a> tags on the homepage and how do i pass the $categores variable to the next template that will load when i click on the <a> tags ??


Top
 Profile  
 
PostPosted: Fri Nov 18, 2016 9:10 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6254
Location: Montreal, Canada
Have you implemented any custom routes? You could then easily pass the parameter into your controller and build your query accordingly.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Bing [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group