Page 1 of 1

How could i print content in metadata stripping the rest

Posted: Wed Dec 04, 2013 3:32 am
by userwords
Ive been looking for a tag that will output whats written inside metadata content quotes.

Unless you tell me there is actually one out there. I suppose the only way to get that data is stripping or choping it using some php + smarty trick.

But im pretty lost.

First because i have no idea if the php would process what i see in the metadata field in content editor: (i use this as default)


Code: Select all

<meta name="description" content=" About those "awesome pages", we will have a look at them. "/>



Or what i find in the already processed metadata tag in the source:


Code: Select all

<base href="http://www.domain.com/" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 
<meta name="description" content=" About those "awesome pages", we will have a look at them. "/>

What im trying to do is to print, what is between:

Code: Select all

<meta name="description" content="
and

Code: Select all

"/>
Or in other words, this:

Code: Select all

About those "awesome pages", we will have a look at them.
Keep in mind description changes for each page, so it is not a constant. But what is immediatly before and after it is indeed a constant. (well, as i share the template in two sites, the base link would also not be a constant)

In case you cannot solve the php smarty part, i would at least need to know from which of the two moments, as seen in content editor, or as seen in the source, would php take to strip, so i can look for help knowing what im asking for php exactly to do.

Respectfully

Re: How could i print content in metadata stripping the rest

Posted: Wed Dec 04, 2013 4:51 am
by chandra
Use {description} tag to do what you want. You can specify it for every page inside option tab. field title

Code: Select all

<meta name="description" content="{description}"/>
For different bases you can use

Code: Select all

<base href="{$smarty.server.SERVER_NAME}" />
Check before the output of the smarty variable. Maybe you have to add some things like HTTP or www cause it can be different from server to server.

If you use {metadata} you have to switch off the output of the base tag

Code: Select all

{metadata showbase=false}

Re: How could i print content in metadata stripping the rest

Posted: Wed Dec 04, 2013 8:57 pm
by userwords
Description tag was the first i looked for, but it prints the title attribute of the page, while im targeting what i put in page metadata content field of meta description.

to entangle it more, ive tried the description tag to be sure and spits nothing.

I did read about that base off parameter, which would make it a bit easier. If anyone have any suggestions im hearing.

Im using latest cmsms 1.11.9 under the horrible name bartolome. If it is a tribute to someone pls take it with humor. I also dislike my own real name :S

Re: How could i print content in metadata stripping the rest

Posted: Sat Dec 07, 2013 1:31 am
by applejack
You need to put {description} in the template in order for it to show.

Re: How could i print content in metadata stripping the rest

Posted: Sat Dec 07, 2013 10:59 am
by Rolf

Code: Select all

{strip}
{process_pagedata}
{content assign='maincontent'}
{/strip}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
{description assign='description'}
{if $description}
<meta name="description" content="{$description}" />
{else}
<meta name="description" content="{$maincontent|strip_tags|strip|truncate:150}" />
{/if}
</head>

< body>
<div id="content">{$maincontent}</div>
< /body>

< /html>

Re: How could i print content in metadata stripping the rest

Posted: Sat Dec 07, 2013 11:59 am
by velden

Code: Select all

<meta name="description" content=" About those "awesome pages", we will have a look at them. "/>
I don't think it is allowed to have those quotes inside. It would make parsing quite difficult/impossible.

For example, what if one would want to have a meta tag like:

Code: Select all

<meta name="description" content="A page about parsing the  content=" About those "awesome pages", we will have a look at them. " meta tag value."/>

Re: How could i print content in metadata stripping the rest

Posted: Mon Dec 30, 2013 7:03 pm
by Dr.CSS
Using double quotes to contain the content= and inside the content= will throw it off or worse case render the page very oddly, use content=" some 'quote' here then"...