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 May 17, 2015 9:08 am

Hi Christoph,

There is another important part to microdata it itemprop="headline" for page titles h1-h7.

For page description required attributes itemprop="description" itemprop="keywords" - these attributes are not valid in combination with name="description" name="keywords" but better attendance than the validity of the pages!

Tell me where to add attributes in the code CMSimple_XH?

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

Re: Doctype in Templates

Post by Termin » Tue May 26, 2015 1:34 pm

Christoph,

How to add attributes to:

<meta itemprop="description" name="description" content="blabla" />
<meta itemprop="keywords" name="keywords" content="blabla" />

<h1 itemprop="headline">title page</h1>
<h2 itemprop="headline">title page</h2>
...

?

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

Re: Doctype in Templates

Post by cmb » Wed May 27, 2015 9:39 pm

Termin wrote:<meta itemprop="description" name="description" content="blabla" />
<meta itemprop="keywords" name="keywords" content="blabla" />
Change function meta() in cmsimple/functions.php to:

Code: Select all

function meta($n)
{
    global $cf, $tx, $print;

    $exclude = array('robots', 'keywords', 'description');
    $value = isset($tx['meta'][$n]) ? $tx['meta'][$n] : $cf['meta'][$n];
    if ($n != 'codepage' && !empty($value) && !($print && in_array($n, $exclude))) {
        $content = XH_hsc($value);
        if (in_array($n, array('keywords', 'description'))) {
            return tag('meta itemprop="' . $n . '" name="' . $n . '" content="' . $content . '"') . "\n";
        } else {
            return tag('meta name="' . $n . '" content="' . $content . '"') . "\n";
        }
    }
} 
Termin wrote:<h1 itemprop="headline">title page</h1>
<h2 itemprop="headline">title page</h2>
Change function content() in cmsimple/tplfuncs.php to:

Code: Select all

function content()
{
    global $s, $o, $c, $edit,  $cf;

    if (!($edit && XH_ADM) && $s > -1) {
        if (isset($_GET['search'])) {
            $search = XH_hsc(stsl($_GET['search']));
            $words = explode(' ', $search);
            $c[$s] = XH_highlightSearchWords($words, $c[$s]);
        }
        $c[$s] = preg_replace(
            '/<h([1-' . $cf['menu']['levels'] . '])([^>]*)>/',
            '<h$1$2 itemprop="headline">',
            $c[$s]
        );
        return $o . preg_replace('/#CMSimple (.*?)#/is', '', $c[$s]);
    } else {
        return $o;
    }
}
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 » Fri May 29, 2015 6:37 pm

Cool thank you Christoph.

---------------------------------

I did a search with the addition of the keyboard controls and added role. id it does not need a search form in css you can define div="search" + form.

Code: Select all

function my_searchbox()
{
    global $sn, $tx;

    return '<form action="' . $sn . '" method="get">' . "\n"
        . '' . "\n"
        . tag(
            'input type="search" name="search" accesskey="f" title="'
            . $tx['search']['label'] . '"'
        ) . "\n"
        . tag('input type="hidden" name="function" value="search"') . "\n" . ' '
        . tag(
            'input type="submit" value="'
            . $tx['search']['button'] . '"'
        ) . "\n"
       . '' . "\n" . '</form>' . "\n";
}

Post Reply