Pulling page or blob from non-cmsms page

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.
Locked
kenisswell

Pulling page or blob from non-cmsms page

Post 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?
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Pulling page or blob from non-cmsms page

Post 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.
kenisswell

Re: Pulling page or blob from non-cmsms page

Post 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.
Last edited by kenisswell on Thu Dec 22, 2005 7:36 am, edited 1 time in total.
mark

Re: Pulling page or blob from non-cmsms page

Post by mark »

would it be possible to grab the whole template?

thanks
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Pulling page or blob from non-cmsms page

Post 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?
mark

Re: Pulling page or blob from non-cmsms page

Post by mark »

how about if we can extract the whole template and place it on a variable  ???
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Pulling page or blob from non-cmsms page

Post by Ted »

Code: Select all

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

Return to “CMSMS Core”