Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7626721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:21:49+00:00 2026-05-31T05:21:49+00:00

I am using the following template library . What I am trying to do

  • 0

I am using the following template library. What I am trying to do is to load one or more upper views inside a template,as an array so that I can easily load them in the template with a for-each loop.

This is a simple example on how it can be used on a controller:

    function index() {

    $data['title']  = 'My page title';

    $partials = array('content'=>'c_location'); //Load view about inside the template.

    $this->template->load('main', $partials, $data);
    }

On the View you have an html like:

    <html>
    ....
    <?=$content?>
    ...
    </html?>

This is what I am trying to use:
Controller:

   $partials = array('content'=>'c_location',
       array(
       'first_upper_content'=>'1_u_location','second_upper_content'=>'2_u_location'
       ) 
   );

So for example I could pass for upper_content, a top header as “first_upper_content” and a slide for “second_upper_content” and then the remainder of the content for “content”.

Html:

    ...
     <?=$upper_content?> 

     <--if upper_content is a array, 
     I could display each content with a for loop-->

     <?=$content?>

When I try everything I get:

Message: pathinfo() expects parameter 1 to be string, array given

Filename: core/Loader.php

Line Number: 759

How can I implement this? I am thinking of modifying the

// Load views into var array

Inside the Template.php & adding a foreach loop to the html;

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:21:49+00:00Added an answer on May 31, 2026 at 5:21 am

    This is what you want:

        // Load views into var array
        foreach(array_flat($view) as $key => $file)
    

    Include the “array_flat” function call in Template.php, as shown above.

    You will need to define this function. You can do this in any auto-loaded helper, or even include it the own Template class (in this case, you should call it as $this->array_flat in the code above). Here is it:

    function array_flat($array)
    {
        $result = array();
    
        foreach ($array as $key => $value)
        {
            if (is_array($value))
            {
                $result = array_merge($result, array_flat($value));
            }
            else
            {
                $result[$key] = $value;
            }
        }
    
        return $result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following xsl template that I'm using to group my xsl. The
This is using the web app framework, not Django. The following template code is
I have the following problem using template instantiation [*]. file foo.h class Foo {
I'm using gcc 4.3.2. I have the following code (simplified): #include <cstdlib> template<int SIZE>
I'm using following peace of code to output an array: echo ======output without array_unique=====;
I'm trying to link to a shared library with a template class, but it
I am looking for a template for hash map that i can rely on,
I'm using delphi6, and it lacks the following abilities: a library object, a list
I have a class Vector<T> , and am using a library that provides a
I'm using the Tapestry5 tapx template library to send an html email, as per

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.