blogarchive

Taking the content from one page and displaying on another can be a very useful tool.  Read on to see the code.

  • Sep 8, 2009
  • Eddie Ballisty
  • Developers

Problem: How do I display content from one page on another?

Solution: Using the Mura tag, I was able to come up with two code blocks that would show the body content.

Using the following block, it's possible to use the filename (url) to grab the body content.

[ mura ]getServiceFactory().getBean('contentManager').getActiveContentByFilename('FILENAME', 'SITEID').getBody()[ /mura ]

 

This code uses the contentID instead.  The contentID can be found in the advanced tab.

[ mura ]getServiceFactory().getBean('contentManager').getActiveContent('CONTENTID', 'SITEID').getBody()[ /mura ]

So if I wanted to use either method, I would create 2 pages.  One named content source and the other named content display. On the content source page, I would put my content.  Then on the content display page, I would use the Mura tag like so:

[ mura ]getServiceFactory().getBean('contentManager').getActiveContentByFilename('content-source', 'SITEID').getBody()[ /mura ]

or

[ mura ]getServiceFactory().getBean('contentManager').getActiveContent('CONTENTID', 'SITEID').getBody()[ /mura ]

Both methods will return the body content.

 

Edit: I wasn't clear about the filename.  To use getActiveContentByFilename(), grab the text in the URL after index.cfm/.  For example:

This page's URL is: /index.cfm/blog/test//blog/how-to-display-content-in-a-separate-page/, so I would take blog/how-to-display-content-in-a-separate-page as the filename.  The final function call would be:

[ mura ]getServiceFactory().getBean('contentManager').getActiveContentByFilename('blog/how-to-display-content-in-a-separate-page', 'mura').getBody()[ /mura ]

Hope that helps!

Developers

Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Michael Evangelista
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Michael Evangelista
Blog Post
By Michael Evangelista
Blog Post
By Grant Shepert
Blog Post
By Matt Levine
Blog Post
By The Mura Team
Blog Post
By Pat Santora
Blog Post
By Pat Santora
Blog Post
By Matt Levine
Blog Post
By Matt Levine
Blog Post
By Matt Levine
Blog Post
By Eddie Ballisty
Blog Post
By Sean Schroeder
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert

Marketers

Blog Post
By Andrew Medal
Blog Post
Blog Post
By Ronnie Duke
Blog Post
By Sean Schroeder