Site Updates
Posted in
1841
4:56 am, June 10, 2022
Site Widget Controls
Currently the widgets on this site, the things on the right hand side, are pretty much automatic and just load in as they please.
Current Widget Load Process:
- Call widget class.
- Add widget into format.
- Call Page
- Page calls widgets or adds widgets
- All widgets are displayed in the same order they are added to the widget class.
View Page, adds widgets to existing widget list
What i would like to have happen:
- Call widget class
- have some default widgets called globally
- be able to override these widgets per page
- be able to order the widgets differently.
How do we achieve this?
I think this can be done with the current widget class.
PHP - widget.class.php
<?php
/*
manage widgets for sidebar
*/
class widgets {
public $widgets;
public $template = "widget.html";
public function __construct() {
}
function add($html) {
$this->widgets[] = $html;
}
function sort() {
asort($this->widgets);
}
function show() {
if(!is_array($this->widgets)) { return; }
$widgets_html = "";
$template = new template($this->template);
foreach ($this->widgets as $key => $html) {
$template->set("html", $html);
$template->set("id", $key);
$widgets_html .= $template->output();
}
return $widgets_html;
}
}
?>
HTML - widget.html
the html wrapper for the widget item
<div class='widget mb-3' id="w[@id]">
[@html]
</div>
..
View Statistics
This Week
43
This Month
192
This Year
591
Add Comment
Other Items in Site Updates
Related Search Terms
Other Categories in Articles
ai api and javascript apps bootstrap data imports docker forster funny images gaming linux marriage minecraft nft newsletters osrs operating systems photoshop pi rs3 slayer random code random things site development site updates tech tool documentation tools and utilities utilities vpn video notes videos web dev windows apps android apple apps atom bootstrap charts code code thoughts comments cooking core crypto css designs factorio games google hardware how to howto ios ideas linux mac music new world osrs php pi400 privacy python random random stats random web code random web things rs3 runescape site bugs slick slider terraria valheim videos web development webdev windows wordpress wow wow classic youtube