Doctype in Templates

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Termin
Posts: 101
Joined: Thu Jan 27, 2011 8:55 am
Contact:

Re: Doctype in Templates

Post by Termin » Sun Feb 08, 2015 12:59 pm

No longer supported pubdate = "pubdate"

now

Code: Select all

if ($pd_current['show_last_edit'] > 0
        && $pd_current['last_edit'] !== ''
    ) {
        $temp = '<time class="entry-date updated" datetime="'
                    . date('c', $pd_current['last_edit'])
                    . '" itemprop="datePublished">'
                    . $plugin_tx['page_params']['last_edit'] .  ' '
                    . date($tx['lastupdate']['dateformat'], $pd_current['last_edit'])
                    . '</time>';
        if ($pd_current['show_last_edit'] == 1) {
        $c[$pd_s] .= $temp;
                } else {
        $c[$pd_s] = $temp . $c[$pd_s];
        }

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Doctype in Templates

Post by cmb » Sun Feb 08, 2015 2:56 pm

Termin wrote:No longer supported pubdate = "pubdate"
Thanks for the update.

I'm still unsure whether we should introduce `itemprop` in the core or a standard plugin. While it is currently part of WHATWG's HTML living standard[1], HTML Microdata are currently only a W3C Working Group Note. The W3C validator will trigger an error on the itemprop attribute:
The itemprop attribute was specified, but the element is not a property of any item.
[1] BTW: "living standard" is an oxymoron.
Christoph M. Becker – Plugins for CMSimple_XH

Termin
Posts: 101
Joined: Thu Jan 27, 2011 8:55 am
Contact:

Re: Doctype in Templates

Post by Termin » Mon Feb 09, 2015 7:23 am

Hi cmb,

your information is out of date, HTML5 W3C recommended and all semantic markup.

http://validator.w3.org/check?uri=http% ... ne&group=0

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Doctype in Templates

Post by cmb » Mon Feb 09, 2015 12:44 pm

Termin wrote:your information is out of date, HTML5 W3C recommended and all semantic markup.
Do you have some references?
Interesting! :)

However: <EDIT>broken link removed</EDIT>. That might be a bug in the validator, though. At least the error message is rather weird.
Christoph M. Becker – Plugins for CMSimple_XH

Termin
Posts: 101
Joined: Thu Jan 27, 2011 8:55 am
Contact:

Re: Doctype in Templates

Post by Termin » Mon Feb 09, 2015 2:17 pm

That might be a bug in the validator, though. At least the error message is rather weird.
This child element without root

Must be the root, like this:

Code: Select all

<!doctype html>
<html lang="">
<head>
<meta charset="utf-8">
<title>Name</title>
<meta itemprop="description" content="" />
<meta itemprop="keywords" content="" />
</head>

<body id="body" onload="" itemscope itemtype="http://schema.org/WebPage">
<header itemscope itemtype="http://schema.org/Blog">
<span itemprop="headline">Site-name</span>
<h2 itemprop="description">Site-description</h2>
</header>

<article role="article" itemscope itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<time class="entry-date updated" datetime="2015-02-05T20:57:37+03:00" itemprop="datePublished">February 05, 2015, 20:57</time>
<h1 itemprop="headline"></h1>
<p>content</p>
</div>
</article>

</body>
</html>

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Doctype in Templates

Post by cmb » Tue Feb 10, 2015 10:00 am

Termin wrote:This child element without root

Must be the root, like this:
Thanks for the explanation. :) (Note to self: RTFM!)

So it makes sense to add the itemscope/itemprop attributes.
Christoph M. Becker – Plugins for CMSimple_XH

Termin
Posts: 101
Joined: Thu Jan 27, 2011 8:55 am
Contact:

Re: Doctype in Templates

Post by Termin » Thu Apr 30, 2015 5:49 pm

Hi cmb,

Code: Select all

function render ()
I'm not sure I could make such a tree in this function, please help me correct change.

Code: Select all

<ul class="menulevel1">
    <li class="doc"><a itemprop="url" href="/?"><span itemprop="name">name level_1</span></a></li>
    <li class="doc"><a itemprop="url" href="/?"><span itemprop="name">name</span></a></li>
        <li class="sdocs"><span itemprop="name">name level_2</span> //active !
            <ul class="menulevel2">
               <li class="doc"><a itemprop="url" href="/?"><span itemprop="name">name</span></a></li>
            </ul>
        </li>
    <li class="doc"><a itemprop="url" href="/?"><span itemprop="name">name level_1</span></a></li>
    <li class="doc"><a itemprop="url" href="/?"><span itemprop="name">name</span></a></li>
</ul>

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Doctype in Templates

Post by cmb » Mon May 11, 2015 10:33 pm

Sorry, for the late reply, Victor.
Termin wrote:I'm not sure I could make such a tree in this function, please help me correct change.
Replace the following functions in cmsimple/classes/Menu.php:

Code: Select all

    /**
     * Renders a menu item.
     *
     * @param int $i The index of the current item.
     *
     * @return string (X)HTML.
     *
     * @global array  The headings of the pages.
     *
     * @access protected
     */
    function renderMenuItem($i)
    {
        global $h;

        if ($this->tf) {
            $html = $this->renderAnchorStartTag($i);
        } else {
            $html ='<span itemprop="name">';
        }
        $html .= $h[$this->ta[$i]];
        if ($this->tf) {
            $html .= '</span></a>';
        } else {
            $html .='</span>';
        }
        return $html;
    }

    /**
     * Renders an anchor start tag.
     *
     * @param int $i The index of the current item.
     *
     * @return string (X)HTML.
     *
     * @access protected
     */
    function renderAnchorStartTag($i)
    {
        $x = $this->shallOpenInNewWindow($i) ? '" target="_blank' : '';
        $x .= '" itemprop="url';
        return a($this->ta[$i], $x) . '<span itemprop="name">';
    }
The code is barely tested, but it seems to work.
Christoph M. Becker – Plugins for CMSimple_XH

Termin
Posts: 101
Joined: Thu Jan 27, 2011 8:55 am
Contact:

Re: Doctype in Templates

Post by Termin » Tue May 12, 2015 8:14 pm

Thank you Christoph, the tree is built correctly. There will be problems, will notify.

Termin
Posts: 101
Joined: Thu Jan 27, 2011 8:55 am
Contact:

Re: Doctype in Templates

Post by Termin » Wed May 13, 2015 10:14 am

best variant

Code: Select all

function renderULStartTags($i)
    {
        global $l;

        $lines = array();
        for ($k = $this->getMenuLevel($i - 1); $k < $this->getMenuLevel($i); $k++) {
            $lines[] = "\n" . '<ul itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement" class="' . $this->st . ($k + 1) . '">' . "\n";
        }
        return implode('<li>' . "\n", $lines);
    }

Post Reply