So this may not be typical...
But what I have is a site in three languages, and a set of XML files that are basically functioning as my database. I have language switching working, and I'm populating the nav based on the <page> and <subpage> nodes in my XML file. Now I'm down to trying to pull in the right content. I want to call a view as associated with my parent page. I can echo the the text from my <view> node, but I haven't been able to use it as part of an include.
Here is the XML:
<page name="home">
<title>Home</title>
<view>views/home.php</view>
<controller>controls/home/home.php</controller>
<content>content/pages/home/home.xml</content>
<subpage name="start-trial">
<title>Start Trial</title>
<view></view>
<controller>controls/trial/trial.php</controller>
<content>content/pages/trial/register.xml</content>
</subpage>
<subpage name="schedule-demo">
<title>Schedule a Demo</title>
<view></view>
<controller>controls/trial/demo.php</controller>
<content></content>
</subpage>
<subpage name="request-quote">
<title>Test 3</title>
<message>Again</message>
</subpage>
</page>
Here is the PHP ($pages) is defined in a separate file. This is what's relevant to this code:
$lang = isset($_GET["lang"]) ? $_GET["lang"] : 'en';
$pages_file = 'content/pages/'. $lang . '.xml';
$pages = simplexml_load_file( $pages_file );
<?php
$mainview = $pages->xpath("page[@name='{$thispage}']/view");
$callmainview = "{$mainview[0]}";
include_once($callmainview.'.php');
?>
I CAN do this:
<?php
$mainview = $pages->xpath("page[@name='{$thispage}']/view");
$callmainview = "{$mainview[0]}";
echo $callmainview;
?>
Thanks in advance for the help. I don't exatly know why this won't work = )