Site Updates
Posted in Site Updates
1801
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:

  1. Call widget class. 
  2. Add widget into format.
  3. Call Page
  4. Page calls widgets or adds widgets
  5. 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:

  1. Call widget class
  2. have some default widgets called globally
  3. be able to override these widgets per page
  4. 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
63
This Month
224
This Year
551

No Items Found.

Add Comment
Type in a Nick Name here
 
Search Articles
Search Articles by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
You want to be the best, you MUST put the long yards in! Nothing comes easy in life so stop wishing and start DOING! So many people would rather bitch and moan than help themselves. Dont be one of those negative drainers, start today, make a small change and keep going forwards with this attitude!
Unknown
Random CSS Property

@viewport

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
min-width (@viewport) css reference