yf_faq user module

Fileplugins/content/modules/yf_faq.class.php
Usemodule('faq'), URL ?object=faq

Public properties

PropertyDefaultDescription
None declared in this class.

Constants

table'faq'

Public methods 3

show

public function show()
    public function show()
    {
        css('
			#faq-search { padding-top: 20px; }
			#faq-items { padding-top: 20px; padding-bottom: 20px; }
			#faq-items li.li-header { list-style: none; display:none; }
			#faq-items li.li-level-0 { display: block; font-size: 15px; }
			#faq-items li.li-level-1 { padding-top: 10px; font-size: 13px; }
			span.highlight { background-color: #ff0; }
		');
        asset('jquery-highlight');
        jquery('
			var url_hash = window.location.hash.replace("/", "");
			if (url_hash) {
				$("li.li-level-0" + url_hash + " .li-level-1", "#faq-items").show();
			}
			$(".li-level-0", "#faq-items").click(function(){
				$(".li-level-1", this).toggle()
			})
			$("input#search", "#faq-search").on("change keyup", function(){
				var words = $(this).val();
				$("#faq-items").unhighlight();
				$("#faq-items").highlight(words);
				$(".li-level-1").hide().filter(":has(\'span.highlight\')").show();
			})
		');
        $items = [];
        foreach ((array) db()->from(self::table)->where('active', 1)->where('locale', conf('language'))->get_all() as $a) {
            $items[$a['id']] = [
                'parent_id' => $a['parent_id'],
                'name' => _truncate(trim($a['title']), 60, true, '...'),
                'link' => url('/@object/#/faq' . $a['id']),
                'id' => 'faq' . $a['id'],
            ];
            if ($a['text']) {
                $items['1111' . $a['id']] = [
                    'parent_id' => $a['id'],
                    'body' => trim($a['text']),
                ];
            }
        }
        return tpl()->parse_string($this->_tpl, [
            'items' => html()->li_tree($items),
        ]);
    }

Methods starting with _ hooks and helpers; not routable as page actions

__call

public function __call($name, $args)

Catch missing method call.

    public function __call($name, $args)
    {
        return main()->extend_call($this, $name, $args);
    }

_hook_sitemap

public function _hook_sitemap($sitemap = false)

Hook for the site_map.

    public function _hook_sitemap($sitemap = false)
    {
        if ( ! is_object($sitemap)) {
            return false;
        }
        $sitemap->_add('/faq?lang=' . conf('language'));
        return true;
    }