Hello,
im working on a award page and wanna use Kirby as CMS, so iam not really sure how i can fix the following synerio:
The Navigation: judge - winner - nominees
Every Nominee has a own lading page, so when the nominated project
become a winner project, how i can move or organize the page to the winner sites?
Any help or thoughts on this?
The question is if you really have to move pages. Wouldn’t it work if you had a select or radio field with these categories, and then filter pages by the value of this field?
yes, i think on that too. How i would grab the content from a other main folder?
so i have a winner and a nominees folder right?
Yes, you can have a nominees and a winner folder. All subfolders would be in the nominee parent. The winner folder would be empty.
Then two templates.
<?php
// nominee.php
$nominees = $page->children()->filterBy('status', 'nominee');
<?php
// winner.php
$winners = page('nominees')->children()->filterBy('status', 'winner');
1 Like
How i can set the status in my blueprint? - i have created a checkbox like this:
winner:
label: Winner
type: checkbox
text: add it to the Winner Page
Is this right? Not sure how to define the status
Yes, you can do it like that.
If you use a checkbox and the checkbox is checked, Kirby will add a “1” in the content file. You can then filter these pages like this:
$winners = page('nominees')->children()->filterBy('winner', '1');
1 Like
texnixe
Split this topic
January 31, 2017, 3:10pm
7
texnixe
Split this topic
January 31, 2017, 3:09pm
9
The filter works fine. Now the problem is, that when iam clicking on a winner project,
the Nav high lighting “Nominees”
How i can make it possible that winner projects will activate right in the nav?
texnixe
January 31, 2017, 4:57pm
11
Could you post your navigation code please?
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-right navbar-nav">
<?php foreach($pages->visible() as $p): ?>
<li<?php e($p->isOpen(), ' class="active"') ?>>
<a href="<?php echo $p->url() ?>"><?php echo $p->title()->html() ?></a>
</li>
<?php endforeach ?>
<li><a href="submit"><button type="submit" class="btn btn-default btn_pt">submit</button></a></li>
</ul>
</div>
i could´t paste the script so here is shot
texnixe
January 31, 2017, 8:46pm
14
What happens when you click on an item? Does the url still show ‘nominees’ for a winner?
The URL still show “nominees” all projects are in this folder
texnixe
January 31, 2017, 9:09pm
16
I think the first thing you should do is create a custom page method to change the url if the page is a winner:
<?php
page::$methods['specialUrl'] = function($page) {
return site()->url() . '/winners/' . $page->uid();
};
In your winners template, you can then use this page method:
<?php
$winners = page('nominees')->children()->visible()->filterBy('winner', '1');
foreach($winners as $winner): ?>
<a href="<?= $winner->specialUrl() ?>">Go to winner</a>
<?php endforeach ?>
Then you need a route to prevent getting the error page at the new url:
c::set('routes', array(
array(
'pattern' => 'winners/(:any)',
'action' => function($uid) {
$page = page('nominees/' . $uid);
if($page) {
return $page;
} else go('error');
}
)
));
With this route, the winners can be reached with a URL like this: http://example.com/winners/winner-one
Navigation:
<nav class="navigation column" role="navigation">
<ul class="menu">
<?php foreach($pages->visible() as $item): ?>
<li class="menu-item<?= r($item->isOpen() || ($item->uid() == 'winners' && $page->winner() == '1'), ' is-active') ?>">
<a href="<?= $item->url() ?>"><?= $item->title()->html() ?></a>
</li>
<?php endforeach ?>
</ul>
</nav>
Thank you for this, i will try it out. So first to get you right:
the first code block i have to create a snippet file?
Where have to put the C:SET … code?
texnixe
February 1, 2017, 8:44am
18
The page method goes into a file in /site/plugins
, I usually have a file methods.php where I put such stuff.
The c::set()
command you can put into your config.php.
I get an error when is use it like this in my Menu Snippet:
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-right navbar-nav">
<?php foreach($pages->visible() as $p): ?>
<li<?php e($p->isOpen() || ($p->uid() == 'winners' && $page->winner() == '1'), ' class="active"') ?>>
<a href="<?php echo $p->url() ?>"><?php echo $p->title()->html() ?></a>
</li>
<?php endforeach ?>
<li><a href="submit"><button type="submit" class="btn btn-default btn_pt">submit</button></a></li>
</ul>
</div>
texnixe
February 1, 2017, 9:26am
20
What sort of error?
(And could you please wrap code blocks within three backticks on a separate line before and after the block? Thank you!
You can click on the edit button to see how it should look)
Maybe your page or the field are named differently?
Yes, always searched for generating cod blocks here, now i know. I get this Error:
This page is currently offline due to an unexpected error. We are very sorry for the inconvenience and will fix it as soon as possible.