Jump to content
Sign in to follow this  
DaveC

Page Not Reading .inc File?

Recommended Posts

This 'partners-page.php' page:

<?php include("./includes/header.inc"); ?>

    <body>
        
    <header class="navbar navbar-inverse navbar-fixed-top" role="banner">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="/"><img src="<?php echo $config->urls->templates?>img/logo.png" alt="ViveSport Logo"></a>
            </div>
            <div class="collapse navbar-collapse">
                <!-- top navigation -->
	<ul class="nav navbar-nav navbar-right"><?php 

		// top navigation consists of homepage and its visible children
		$homepage = $pages->get('/'); 
		$children = $homepage->children();

		// make 'home' the first item in the navigation
		$children->prepend($homepage); 

		// render an <li> for each top navigation item
		foreach($children as $child) {
			// Exclude pages with certain names from the main navigation
			if($child->name != 'legal') {
				if($child->id == $page->rootParent->id) {
					// this $child page is currently being viewed (or one of its children/descendents)
					// so we highlight it as the current page in the navigation
					echo "<li class='active'><a href='$child->url'>$child->title</a></li>";
				} else {
					echo "<li><a href='$child->url'>$child->title</a></li>";
				}
			}
		}

		// output an "Edit" link if this page happens to be editable by the current user
		if($page->editable()) {
			echo "<li class='edit'><a href='$page->editUrl'>Edit</a></li>";
		}

	?></ul>
            </div>
        </div>
    </header><!--/header-->

        
         <!-- Page Title -->
		<div class="section section-breadcrumbs">
			<div class="container">
				<div class="row">
					<div class="col-md-12">
						<h1><?php echo $page->title; ?></h1>
					</div>
				</div>
			</div>
		</div>
        
        <div class="section">
	    	<div class="container">
				<div class="row">
				<div class="col-sm-4">
				<img src="<?php echo $config->urls->templates?>img/<?php echo $page->pageimage; ?>" alt="" class="img-responsive">
				</div>
					<div class="col-sm-8">
<h1>testing</h1>
		

<?php include("./includes/partners.inc"); ?>	

<h3>3rd test</h3>					
					</div>
				</div>
			</div>
		</div>

<hr>
		
<?php include("./includes/footer.inc"); ?>

    </body>
</html>

calls this 'partners.inc' file:

<?php 
// render the list of partners

// get an array of all child pages, hidden or not, but with a template called partners-page
$children = $page->children('include=all, template=partners-page');
    // loop through the array and output markup for each child
    foreach($children as $child) {
   ?>     
        <h2>5th test</h2>

	<div class="row">
		<div class="col-md-3">
			<img src="<?php echo $child->partner_logo->url; ?><?php echo $child->partner_logo; ?>" />
		</div>
		<div class="col-md-9"> 
        <h2>4th test</h2>
			<h1><?php echo $child->title; ?></h1>
			<p><?php echo $child->body; ?></p>
			<p><?php echo $child->image; ?></p>
			<p><a href="<?php echo $child->partner_link; ?>" target="_blank"><?php echo $child->partner_link; ?></a></p>
		</div>
	</div>
<hr>
<?php
        }
?>

The .php page appears to work since the 'test' messages show up. Nothing shows from the .inc file ['5th test', title, body] apart from '4th test' which appears after the footer on the page http://www.vivesport.co.uk/what-we-offer/.

Either the .inc file is not being called correctly or there is an error within the .inc file.

Suggestions gratefully received.

[Please don't remind me about edit/login showing - one step at a time!]

Share this post


Link to post
Share on other sites

I couldn't go through all the cope you pasted but I'd suggest this simple test. In each .inc file, do this:

echo 'Hello from INSERT_INC_NAME';// replace INSERT_INC_NAME with respective inc's name

Then look at the output. It may be that there are no child pages to display, hence no output.

Share this post


Link to post
Share on other sites

I'd missed a crucial line of code out!

Apologies for taking up your time.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...