Page 1 of 1

Pulling page or blob from non-cmsms page

Posted: Wed Dec 21, 2005 8:37 am
by kenisswell
I have a pre-existing site where have installed CMSMS but I do not really want to re design the entire site around CMSMS. That is really over kill for me. I really only need to be able to use CMS on a few sections (ie blobs) of a page or two. Basically I need certain sections of a page to be easy to edit by non-html savvy folks, but the rest of the site will be a traditional static site.

So I am thinking of a some what back-wards approach to CMS. I was looking for a way to "Pull" content from CMSMS into a non-CMSMS page. For instance, could I use a php include (or something like) from my site's pages that to "pull" a blob (or even a entire page) from my CMSMS 

For example: from my site /www/todaysnews.php I would include some blob from /www/cms/currentweather_blob). Then I would make currentweather_blob editable via CMSMS

Is that possible? Can someone show me a code example? Is there a better way?

Re: Pulling page or blob from non-cmsms page

Posted: Thu Dec 22, 2005 3:29 am
by Ted
I decided to play with this a little bit this evening before bed.  Make a file called external.php in your cmsms directory.  For the code, put in:

Code: Select all


<?php

include_once(dirname(__FILE__).'/include.php');

function cms_external_html_blob($blobname)
{
        global $gCms;
        $smarty =& $gCms->smarty;

        return $smarty->fetch('htmlblob:'.$blobname);
}

?>
Then in your calling page, do:

Code: Select all

include_once('/dir/to/cmsms/external.php');
echo cms_external_html_blob('footer');
Works fine for me.  Neat idea.

Re: Pulling page or blob from non-cmsms page

Posted: Thu Dec 22, 2005 5:59 am
by kenisswell
:D Thanks for the quick response and the great little tool. I tested it and it works good so far. Are there other objects that I could pull from CMSMS besides blobs?

Someone should document this and give it a name. (like "Pull from CMSMS")


*I could not get it to work at all on version 0.10.4. But it does work in V.11.2.

Re: Pulling page or blob from non-cmsms page

Posted: Sat Jan 07, 2006 4:28 am
by mark
would it be possible to grab the whole template?

thanks

Re: Pulling page or blob from non-cmsms page

Posted: Sat Jan 07, 2006 3:23 pm
by Ted
Well, the issue is that it's going to grab the template, but smarty will then process it into a resulting page.  Is this what you want?  Or you want the template with the smarty tags ({content}, etc) still in it?

Re: Pulling page or blob from non-cmsms page

Posted: Sun Jan 08, 2006 2:47 am
by mark
how about if we can extract the whole template and place it on a variable  ???

Re: Pulling page or blob from non-cmsms page

Posted: Sun Jan 08, 2006 3:50 am
by Ted

Code: Select all

include_once(dirname(__FILE__).'/include.php');
$thetemplate =& TemplateOperations::LoadTempateById($id);
$templatetext = $thetemplate->content;
That's the unprocessed template contents.