How could i print content in metadata stripping the rest

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
userwords
Forum Members
Forum Members
Posts: 48
Joined: Mon Dec 27, 2010 12:27 am

How could i print content in metadata stripping the rest

Post 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
chandra

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

Post 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}
userwords
Forum Members
Forum Members
Posts: 48
Joined: Mon Dec 27, 2010 12:27 am

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

Post 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
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

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

Post by applejack »

You need to put {description} in the template in order for it to show.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

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

Post 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>
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

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

Post 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."/>
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

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

Post 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"...
Post Reply

Return to “CMSMS Core”