Feed CMSMS menu through to Wordpress [SOLVED]

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
JM6891
Forum Members
Forum Members
Posts: 150
Joined: Thu Mar 18, 2010 2:35 pm

Feed CMSMS menu through to Wordpress [SOLVED]

Post by JM6891 »

I'm not sure if this is possible or if there is a module to achieve what we need here, but is it possible to feed a navigation menu from CMSMS to a Wordpress template?

A client of ours has a CMSMS site and a Wordpress blog. They both have the same theme, but menu on the Wordpress blog is static (it reflects the CMSMS menu but is updated via the template manually).

This hasn't been an issue up until now as the page names didn't change frequently, but I'm just wondering if it is possible to make this a bit more userfriendly so that the wordpress templates don't have to be updated manually?
Last edited by JM6891 on Mon Feb 24, 2014 4:27 pm, edited 1 time in total.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Feed CMSMS menu through to Wordpress

Post by Rolf »

This is why I made http://dev.cmsmadesimple.org/projects/cacheremotefile
I use it for several sites, in example the menu of the docs site is taken from the main cmsms site.
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
JM6891
Forum Members
Forum Members
Posts: 150
Joined: Thu Mar 18, 2010 2:35 pm

Re: Feed CMSMS menu through to Wordpress

Post by JM6891 »

Thank you very much Rolf. I shall take a look at that module.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Feed CMSMS menu through to Wordpress

Post by Rolf »

JM6891 wrote:Thank you very much Rolf. I shall take a look at that module.
It is a tag/plugin ;-)
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
JM6891
Forum Members
Forum Members
Posts: 150
Joined: Thu Mar 18, 2010 2:35 pm

Re: Feed CMSMS menu through to Wordpress

Post by JM6891 »

Hi Rolf, did you say there was an example somewhere?

Thanks
JM6891
Forum Members
Forum Members
Posts: 150
Joined: Thu Mar 18, 2010 2:35 pm

Re: Feed CMSMS menu through to Wordpress

Post by JM6891 »

Don't worry I've found the help text in the php file!
JM6891
Forum Members
Forum Members
Posts: 150
Joined: Thu Mar 18, 2010 2:35 pm

Re: Feed CMSMS menu through to Wordpress

Post by JM6891 »

Hi Rolf,

I have installed the tag and created the necessary blank template and hidden page. I can see that cache files have been created in the tmp/cache_remote_file directory.

Do you know how I would retrieve the information from this onto a Wordpress site? So my cmsms is the master site and the Wordpress site is the 'recipient' site. I assume the following smarty tag is for use on other cmsms websites?

Code: Select all

{cache_remote_file url="http://www.website.com/index.php?page=page_alias"}
Any help or pointers in the right direction would be very much appreciated as I'm a php noob.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Feed CMSMS menu through to Wordpress

Post by calguy1000 »

This involves just a few easy steps.

a: create a simple page template with just {content} in it. lets call this 'basic'
b: create a new content page using the basic template, lets call this 'menu-only'
- in that page include your menu tag. {menu} or whatever you need.
- mark that page as not searchable, not visible in menu, but cachable
- note the url to this page.

Browsing to that url... like: "www.mysite.com/index.php?page=menu-only should now output the HTML code for the navigation, and ONLY that html code.

That's all you have to do with CMSMS. The rest of the work is done in your other system. Syntax and methods may vary.

c: include that URL in your code for the other system. something like:

Code: Select all

echo file_get_contents('http://www.mysite.com/index.php?page=menu-only');  // requires allow-url-fopen
d: OPTIONAL
if you want the menu cached in wordpress or your other system, and allow-url-fopen is turned on you can use a method like this (untested) to cache the file

Code: Select all

$cache_file = 'some_temporary_location';
if( !file_exists($cache_file) || filemtime($cache_file) < time() - 3600 ) {
  @copy('http://www.mysite.com/index.php?page=menu-only',$cache_file);
}
echo file_get_contents($cache_file);
NOTE:

Using the same methodology, with a few more steps you could also have the other system using the CMSMS stylesheets.
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
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Feed CMSMS menu through to Wordpress

Post by Rolf »

Ohw, you need CMSMS -> WP in that case my tag won't help you...
Try Calguy's solution!
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: Feed CMSMS menu through to Wordpress

Post by JohnnyB »

I used to use an old plugin that would cache the menu to a file and then I would include that file using PHP into the WP template. Robert's example seems easy.

But, shouldn't something like this work too?
A UDT that writes the menu to a file? And then the file can be included into the WP template.

UDT

Code: Select all

$config = cmsms()->GetConfig();
// params
if (isset($params['filename']) && $params['filename'] != '') {
$filename = $params['filename'];
} else {
$filename = 'my_menu';
}
if (isset($params['expire']) && $params['expire'] != '') {
$expire = $params['expire'];
} else {
$expire = 60; // default 1 hour
}

if (isset($params['template']) && $params['template'] != '') {
$tpl_name = $params['template'];
} else {
echo 'template is required';
}
if( endswith($tpl_name, '.tpl') ) {
$usefile = true;
} else {
$usefile = false;
}

// set menu path and name
$tmpdir = $config['css_path']; // path to /tmp/cache/
$File = $tmpdir."/".$filename.".inc";

// check if menu exists and the age.  Show cached menu or generate a new one
$menucache = time() - ($expire * 60);
$menudate = file_exists($File) ? filemtime($File) : -1;

if ($menudate > $menucache) {
// do nothing
} else {
$menumgr = cms_utils::get_module('MenuManager');
if ($usefile) {
$menu = $menumgr->ProcessTemplate($tpl_name);
} else {
$menu = $menumgr->ProcessTemplateFromDatabase($tpl_name);
}

file_put_contents($File,$menu);
}
Call it in a template like
{cachedmenu template='YourMenuTemplate' filename='menu'}

Right now, I'm just getting an empty file. :(
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
JM6891
Forum Members
Forum Members
Posts: 150
Joined: Thu Mar 18, 2010 2:35 pm

Re: Feed CMSMS menu through to Wordpress

Post by JM6891 »

Calguy's solution has worked perfectly for me, so thank you very much for your help!

Thank you to all who responded to this post too.
Post Reply

Return to “Modules/Add-Ons”