... was created by me to have my todo list on the website. Now I use it as a kind of dashboard that shows my drafts and unlisted posts.
Last active
October 11, 2023 20:05
-
-
Save pftnhr/6210e410339d2513c8d2cf1fbebe7d7a to your computer and use it in GitHub Desktop.
[datenstrom-yellow] A ToDo page/Dashboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $this->yellow->layout("header") ?> | |
<h1><?php echo $this->yellow->page->getHtml("titleContent") ?></h1> | |
<?php echo $this->yellow->page->getContentHtml() ?> | |
<h2>Drafts</h2> | |
<?php $drafts = $this->yellow->content->index(true)->filter("status", "draft")->sort("published", false) ?> | |
<ul> | |
<?php foreach ($drafts as $draft): ?> | |
<li> | |
<a class="entry-link" href="<?php echo $draft->getLocation(true) ?>"><?php echo $draft->getHtml("title") ?></a> | |
</li> | |
<?php endforeach ?> | |
</ul> | |
<h2>Unlisted</h2> | |
<?php $unlisteds = $this->yellow->content->index(true)->filter("status", "unlisted")->sort("published", false) ?> | |
<ul> | |
<?php foreach ($unlisteds as $unlisted): ?> | |
<li> | |
<a class="entry-link" href="<?php echo $unlisted->getLocation(true) ?>"><?php echo $unlisted->getHtml("title") ?></a> | |
</li> | |
<?php endforeach ?> | |
</ul> | |
<?php $this->yellow->layout("footer") ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--------------------------- | |
todo.php | |
Dexcription: This simple extension adds a new status "todo" to Yellow that I use to create a kind of dashboard that can only be accessed when I am logged in. See "navigation-snippet.html". | |
The todo.html is the associated layout file where I display drafts and unlisted pages. | |
Created by Robert Pfotenhauer on 03.10.23. | |
----------------------------> | |
<?php | |
// Todo extension | |
class YellowTodo { | |
const VERSION = "0.8.18"; | |
public $yellow; // access to API | |
// Handle initialisation | |
public function onLoad($yellow) { | |
$this->yellow = $yellow; | |
} | |
// Handle page meta data | |
public function onParseMetaData($page) { | |
if ($page->get("status")=="todo") $page->visible = false; | |
} | |
// Handle page layout | |
public function onParsePageLayout($page, $name) { | |
if ($this->yellow->page->get("status")=="todo" && $this->yellow->lookup->getRequestHandler()=="core") { | |
$errorMessage = ""; | |
if ($this->yellow->extension->isExisting("edit")) { | |
$errorMessage .= "<a href=\"".$this->yellow->page->get("editPageUrl")."\">"; | |
$errorMessage .= $this->yellow->language->getText("todoPageError")."</a>"; | |
} | |
$this->yellow->page->error(420, $errorMessage); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment