add something to page metadata with UDT

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
Wiedmann
Forum Members
Forum Members
Posts: 233
Joined: Wed Mar 26, 2008 1:49 am
Location: Stuttgart / Germany

add something to page metadata with UDT

Post by Wiedmann »

Hallo,

is it possible to add something to the page metadata (HEAD section of the HTML output) within a plugin (or UDT)? In particular I want add some "..." or "..." blocks to the HEAD section.

Regards,
Carsten
alby

Re: add something to page metadata with UDT

Post by alby »

Wiedmann wrote: is it possible to add something to the page metadata (HEAD section of the HTML output) within a plugin (or UDT)? In particular I want add some "..." or "..." blocks to the HEAD section.
Yes, but UDT is php code, why don't use GBC (plain html)?

Alby
Wiedmann
Forum Members
Forum Members
Posts: 233
Joined: Wed Mar 26, 2008 1:49 am
Location: Stuttgart / Germany

Re: add something to page metadata with UDT

Post by Wiedmann »

I think my problem was not clear enougt...

I'm working on a tag (CMSForge), which other CMSms users can install in their plugin directory. The tag is called with "{pluginname param1 param2 ...}" in the user template.

Now in smarty_cms_function_pluginname() I have "a lot" of PHP code which produce and return HTML. Part of this code is "JS code". But I don't want have this javascript in the returned HTML code, instead I want have this javascript in den section of the page.

Maybe in the future, a "style declarations" will also be part of the returned HTML code. But "" is not allowed in "". Thus this part must be in "".

(BTW: The FormBuilder module have the same bug, and puts a "" block in the output ( section) with the default installation/settings)
alby

Re: add something to page metadata with UDT

Post by alby »

Wiedmann wrote: Now in smarty_cms_function_pluginname() I have "a lot" of PHP code which produce and return HTML. Part of this code is "JS code". But I don't want have this javascript in the returned HTML code, instead I want have this javascript in den section of the page.
Add your UDT tag in head section of your template (same of {title},{metadata},.. tags):
{pluginname param1 param2 ...}

Alby
Wiedmann
Forum Members
Forum Members
Posts: 233
Joined: Wed Mar 26, 2008 1:49 am
Location: Stuttgart / Germany

Re: add something to page metadata with UDT

Post by Wiedmann »

No, the script and style is only a part of the output...

a little more(hyphotetic) code:
function.mytag.php

Code: Select all

<?php
function smarty_cms_function_mytag($params, &$smarty)
{
    // other PHP code
    $result = '
        <style type="text/css">
            /* <![CDATA[ */
            /* some style declaratiions */
            .form {background-image:url(background.gif);}
            .field {background-color:#ffa;}
            .button {background-color:#aaa;}
            /* ]]> */
        </style>

        <__script__ type="text/javascript">
        function sendForm () {
            /* <![CDATA[ */
            //some javascript code
            return true;
            /* ]]> */
        }

        <!-- some HTML markup -->
        <form name="testform" action="" onsubmit="return sendForm();" class="form">
            <input name="field1" type="text" class="field" value='.$params['field'].'/>
            <input type="submit" class="button" />
        </form>';

    return $result;
}
?>
As you can see, the result of this tag is not valid html. Especially the style must go the section. Ad the javascript should also go there. The rest is normal page content.

And no, I don't want use inlinestyle... Just installing this plugin and using it with "{mytag field='foo'}" should be enough for the user.

(BTW: Just look to the output of a standard FormBuilder form, and you can see the problem.)

Or a simiar example to explain:

Code: Select all

<?php
function smarty_cms_function_mytag($params, &$smarty)
{
    $pageinfo =& $GLOBALS['gCms']->variables['pageinfo'];
    echo $pageinfo->content_metadata;
}
?>
With this code I can see the metadata of the current page. How can I edit this metadata?
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm
Location: Comox Valley, BC

Re: add something to page metadata with UDT

Post by Nullig »

Each page has a metadata field. Can it be placed there?

Nullig
Wiedmann
Forum Members
Forum Members
Posts: 233
Joined: Wed Mar 26, 2008 1:49 am
Location: Stuttgart / Germany

Re: add something to page metadata with UDT

Post by Wiedmann »

Can it be placed there?
No, have you ever seen this?:

Code: Select all

<__html>
<head>
<form>...</form>
</head>
</__body><__body>
</__html>
(look the position of the form)

The result, only with using the tag in a page template, must be something like:

Code: Select all

<__html>
<head>
<style>...</style>
<__script__>...</__script>
</head>
</__body>
<form>...</form>
<__body>
</__html>
Each page has a metadata field.
Exact, and that's the question for the developers (you?):
Is there a CMS or Smarty function to change this page metadata within a plugin or UDT?

(Have you now test the FormBuilder module and looked at the output?)
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm
Location: Comox Valley, BC

Re: add something to page metadata with UDT

Post by Nullig »

No, I'm not one of the developers, but it would seem that there should be a way of "trapping" and manipulating that field data from the content somewhere between pulling it from the db and rendering it.

Nullig
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: add something to page metadata with UDT

Post by calguy1000 »

actually, no, there is no way in the modules to effect the metadata.

At least not in 1.2.3

that's why for things like the {embed} tag you have to put one tag in the header, and another tag into the page content somewhere.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm
Location: Comox Valley, BC

Re: add something to page metadata with UDT

Post by Nullig »

The easiest way would be to provide info in the help section of the plugin for the user to add the appropriate javascript to the head portion of their template, if they want to have valid XHTML. That way they could create a specific template for the pages that use the tag.

Nullig
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm
Location: Comox Valley, BC

Re: add something to page metadata with UDT

Post by Nullig »

See this post by calguy...

http://forum.cmsmadesimple.org/index.ph ... #msg102120

There might be a way to do this.

Nullig

PS @ Wiedmann - I've sent you some PMs, but not heard back.
Last edited by Nullig on Wed Apr 09, 2008 12:17 am, edited 1 time in total.
Post Reply

Return to “Developers Discussion”