Forum
Data select isn't working correctly.
Perch: 3.0.8, PHP: 7.0.19, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.0.8), assets (3.0.8), categories (3.0.8)
App runtimes: <?php $apps_list = [ ];
PERCH_LOGINPATH: /test/christie/perch
PERCH_PATH: /home/studiowolf/domains/studiowolf.be/public_html/test/christie/perch
PERCH_CORE: /home/studiowolf/domains/studiowolf.be/public_html/test/christie/perch/core
PERCH_RESFILEPATH: /home/studiowolf/domains/studiowolf.be/public_html/test/christie/perch/resources
Image manipulation: GD
PHP limits: Max upload 64M, Max POST 64M, Memory: 128M, Total max file upload: 64M
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
Resource folder writeable: Yes
SCRIPT_NAME: /test/christie/perch/core/settings/diagnostics/index.php
REQUEST_URI: /test/christie/perch/core/settings/diagnostics/
DOCUMENT_ROOT: /home/studiowolf/domains/studiowolf.be/public_html
HTTP_HOST: studiowolf.be
Hello,
I've just installed the latest Perch 3 version. I want a data-select for this page: https://studiowolf.be/test/christie/shop-christies-interieur-perch.php. When customer uploads a new product, he/she can choose a product categorie (antiques, lighting, tables, ...). When there is a visitor, he can select a categorie in the top bar to only display the correct items. https://studiowolf.be/test/christie/categories.php
Portfolio filter on shop-christies-interieur-perch.php
<li class="activeFilter"><a href="#" data-filter="*">Show all products</a></li>
<li><a href="#" data-filter=".pf-antiques">Antiques</a></li>
<li><a href="#" data-filter=".pf-lighting">Lighting</a></li>
<li><a href="#" data-filter=".pf-storage">Storage</a></li>
<li><a href="#" data-filter=".pf-tables">Tables</a></li>
<li><a href="#" data-filter=".pf-mirrors">Mirrors</a></li>
<li><a href="#" data-filter=".pf-accessories-objects">Accessories and Objects</a></li>
<li><a href="#" data-filter=".pf-seating">Seating</a></li>
<li><a href="#" data-filter=".pf-other">Other</a></li>
<?php perch_content('shop-toevoegen'); ?>
shop-toevoegen.html:
<article class="col-md-3 portfolio-item <perch:content id="category" type="dataselect" label="Selecteer Product categorie" page="/categories.php" region="Categories" options="categoryName" values="categorySlug" />">
<div class="portfolio-image">
<a href="#">
<img src="<perch:content id="images" type="image" label="Afbeelding product" width="400px" height="300px" crop="true" />" >
</a>
</div>
<div class="portfolio-desc-b">
<h3><perch:content id="titel_product" type="smarttext" label="Unieke titel product" required="true" title="true" /></h3>
<span><perch:content id="body" type="textarea" label="Korte beschrijving product" html="true" editor="ckeditor" size="m" required="false" /><br><a href="mailto:shop@christiesinterieur.be?SUBJECT=Question%20about%20<perch:content id="titel_product" type="text" label="Unieke titel product" required="true" escape="true" urlencode="true" />" class="button button-border button-rounded button-fill button-dark"><span>Meer info</span></a></span>
</div>
</article>
categories.php
<p><?php perch_content('categorie-toevoegen'); ?></p>
categories.html
<perch:content id="categoryName" type="text" label="Category name" required="true" />
<perch:content id="categorySlug" type="slug" for="categoryName" hidden="true" />
What am I doing wrong? Is a less complex configuration possible instead of working with an extra categories.php page?
Kind Regards, Frederic
I don't really follow. What problem are you seeing?
I see the data-select in the CMS, but it doesn't work. I don't see the different categories (like lighting, tables, mirrors, ...). It's empty. When I'll be able to select a categorie, the image filter will work on the page.
Hello Frederic,
If I understand correctly, I think you want:
For (1), assuming all product categories are in a set called 'Products' you can add this to your template:
For (2), have a look at the Category Filtering in the documentation.
Hope this helps!
I don't understand 100%. So I have to place the perch:categories in my shop-toevoegen.html file like this? How/where can I define the products set?
To add a set:
You may also find the Category Template documentation helpful.
I don't see the solution. Maybey I have to make it more clear.
This is my original filter on my html page, now php:
When selecting f.e. "Antiques", the data-filter sorts the articles with ".pf-antiques", in the class of the article:
What is the best way to do this? I suppose replace the pf-antiques in <article class="col-md-3 portfolio-item pf-antiques"> with some perch content?
Ok so you just want to to add a class to the
<article>
with the Category's slug prefixed bypf-
?This still requires you to have all the categories in a set called Products. You can call it whatever you want, just change the
set
value in your code.OK this works! Thx a lot!
One other question: how can I limit to choose only 1 option/category?
Now I can choose more categories, but then the datafilter doesn't work. Solution is to make a second perch:categories, then it works, but I can still choose multiple categories within 1 perch-categories.
You can use
max="1"
You can add a
max
attribute to your<perch:categories>
to specify the maximum number of categories that can be selected: