Roych Posted July 6, 2021 Share Posted July 6, 2021 Hello, I need some help please. I'm working on sortable "portfolio" site wich is working great so far. I have categories (page select field = "objekt_select") that one can select when creating a new portfolio item. (Categories are made up front and are always the same even if they are empty.) I would like to show some text when the categorie is empty. (expl.: This categorie is empty.) So my code look like this, with one of my failed atempts. <article class="col-md-4 text-left"> <div class="about-content-main pad-common high-bg border-top-white"> <h2 class="inner-heading white-text">Buildings</h2> <span class="liner-small"></span> <ul id="mediafolio-filter" class="mediafolio-filter clearfix"> <li class="filter" data-filter="all">All</li> <?php $objekt_select = $pages->find("parent=1026");?> <?php foreach ($objekt_select as $item) : ?> <li class="filter" data-filter="<?= $item->name ?>"><?=$item->title ?> (<?=$pages->count("template=uporabnik, objekt_select=$item")?>)</li> <?php endforeach; ?> </ul> </div> </article> </div> <!-- row:ends --> <div class="list mediafolio-thumb-wrap row"> <?php foreach ($page->find('template=uporabnik, sort=random') as $single ):?> <!-- MY Attempt, but not working --> <?php if ($single->count('template=uporabnik, objekt_select=$single') < 1) : ?> <!-- grid-item:starts --> <article class="mediafolio-grid mix all <?php echo $single->objekt_select->implode(' ', 'name') ?> zoom"> <a href='<?=$single->url?>'><img title="<?=$single->title?>" alt="<?=$single->slike_uporabnik->description?>" class="img-responsive homeimg" src="<?=$single->slike_uporabnik->url?>"></a> <div class="mediafolio-caps"><a class="item-title" href='<?=$single->url?>'><?=$single->title?></a> / <?php if ($single->objekt_select->implode(' / ', 'title')) :?> <?php echo $single->objekt_select->implode(function($item) { return "<span><a href='$item->url'>$item->title</a> / </span>"; }); ?> <?php else :?><?php endif ;?> </div> </article> <!-- grid-item:ends --> <?php else :?><h2>There are no items in this category!</h2><?php endif ;?> <?php endforeach; ?> I'm not very good with PHP so any help is appreciated. Thank you very much ? R Link to comment Share on other sites More sharing options...
teppo Posted July 6, 2021 Share Posted July 6, 2021 I must admit that I'm not really following your logic here: <?php foreach ($page->find('template=uporabnik, sort=random') as $single ):?> <!-- MY Attempt, but not working --> <?php if ($single->count('template=uporabnik, objekt_select=$single') < 1) : ?> First you're iterating over all the children of current page that use the uporabnik template. It's a bit unclear what exactly that "current page" is, but assuming that it has visible "uporabnik" pages below it, this should find them. In the next step you're checking if individual uporabnik pages also have children using the uporabnik template... but these children must refer to their parent page via the objekt_select field. I'm pretty sure that there's some sort of confusion here (that latter selector doesn't seem to make much sense), but since I don't know what your page tree looks like, I'm just guessing here. Could you provide an example of how these pages are structured in the page tree, which templates are used where, and where in that structure are we now (in this example)? That would be helpful in figuring out what exactly is going on ? Link to comment Share on other sites More sharing options...
Roych Posted July 6, 2021 Author Share Posted July 6, 2021 hello sorry for confusion ? my tree looks like this HOME - USERS (template = Uporabniki) - User 1 (template = Uporabnik) - User 2 (template = Uporabnik) - .... OBJEKTI (template = Objekti) "This are Categories" - Objekt 1 (template = Objekt) - objekt 2 (template = Objekt) - ..... There is the url to the site, so you can see how it works. Under (GARAŽA) you will see that it is empty and there I would like to show the text. https://pekarna.info/ Thank you R Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now