Can I add an include in with page text?

6 posts by 2 authors in: Forums > CMS Builder
Last Post: January 31, 2014   (RSS)

I wasn't sure if I was going to explain this correctly so I took a screen shot.  Is it possible to add and include to a page - but WITHIN the text (as the client would enter it in their admin section)

I want to create a contact include so if something changes - it can be changed from 1 location. But it won't be on every page and it's within the text area.  (see screenshot)
<!--?php include "include_contact.php"; ?-->

Here's the page: http://www.irmahotelcody.com/sec.php

Attachments:

picture-24.png 143K

I have done that in the past to allow the user to add an RSVP form in the text.  Here is where I got the solution:

http://www.interactivetools.com/forum/forum-posts.php?postNum=2231659#post2231659 

Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987

Thanks Ron!! 

I have had a challenging few weeks so I guess this is nothing out of the ordinary but I think I'm doing something wrong. 

The contact-info.php & contact-info2.php pages are dynamically created and although they contain the same info on both pages - they come up fine by themselves ( http://www.irmahotelcody.com/contact-info.php )

I changed "blog" to "menus", change the inserted file names  & added "#insert_contact#" into the 'content' field on the menus page.
The page just comes up blank in the browser so I deleted the #insert_content# and same result so I put them back in. That's telling me it's something in the header. I pasted it below - maybe you can see something that I'm not.  Thanks!!!!

http://www.irmahotelcody.com/menus-restaurant-dining-cody-wy2.php


// load record from 'menus'   
list($menusRecords, $menusMetaData) = getRecords(array(     
'tableName'   => 'menus',     
'where'       => '', // load first record     
'loadUploads' => true,     'allowSearch' => false,     
'limit'       => '1',   
));   
$menusRecord = @$menusRecords[0]; // get first record   
if (!$menusRecord) { dieWith404("Record not found!"); } // show error message if no record found  

<!--INSERT PLACEHOLDER BEGIN-->      
//Create an array of placeholders to file names   
$insertArray = array(     
"#insert_contact#"  => 'contact-info.php',     
"#insert_contact2#" => 'contact-info2.php'   );   

//Set content that will contains placeholders to a varaible   
$content = $menusRecord['content'];      

//Cycle through placeholders   
foreach($insertArray as $placeholder => $file){     
//If the content contains the placeholder....     
if($startNum = strrpos($content , $placeholder)){       
//Create and object and include the file to 'run' the code       
ob_start();       
include($file);       

//Add objects content to a placeholder content variable       
$placeholderContent = ob_get_clean();       
//Replace placeholder with replace holder content       
$content = str_replace($placeholder, $placeholderContent, $content);     }   }   

//Display completed content   
echo $content;

<!--INSERT PLACEHOLDER END--> 
?>

oh for pete's sake... I took these out and now I'm getting something - still not right but at least it's showing up which gives me something to work with! 

<!--INSERT PLACEHOLDER BEGIN-->

<!--INSERT PLACEHOLDER END-->