Jump to content

Included in another script


Mike
 Share

Recommended Posts

Hi!

I´m a new user of processwire and i have the next problem.

When i include the sequence in my program i get an error:

Error Call to undefined method Template::getTableData()

I need help please

Thanks!

Link to comment
Share on other sites

Thanks! but I have solved the problem.

Now me a new problem to include the following lines:

require_once("pw/index.php");

.

.

.

$this->data['cms'] = $wire->pages->get("/about/what/");

My page says:

The page you requested cannot be found!

Surely I`ve missed some step.

Thanks!

Link to comment
Share on other sites

require_once("pw/index.php");

This may not be a safe inclusion because it's not specific enough. It's going to search all of PHP's paths for a "pw" dir before it searches the current dir. So be sure to complete that to a absolute or relative path. Absolute meaning a full "/path/to/pw/index.php" or relative meaning one that starts with a dot, i.e. "./pw/index.php" or "./index.php" or whatever it is relative to your PW installation.

Also, for your API call, I suggest using wire('pages')->get() rather than $wire->pages->get().

Link to comment
Share on other sites

Mike can you give us a lot more detail? Are you creating a page in the admin or in the API? If in the API, is this from a template, a module or from a command line script? If you think screenshots would be helpful, please include that too.

Link to comment
Share on other sites

Ok Ryan, my problem is that I have included this code in my phpprogram through a controller.

<?php

class ControllerCommonCMS extends Controller {

public function index() {

//includes the path that contains the variable

require_once("pw/index.php");

//mypage contains the page

$mypage = wire('pages')->get("/ourguarantee");

}

}

?>

I have to do to display the page?

Thanks!

Link to comment
Share on other sites

Thank you very much Ryan!

Now it has emerged the following problem:

Error Uncaught exception 'WireException' with message 'Page /ccsMA/ourguarantee/ may not be rendered because outputFormatting is set to false

But i have solved including:

wire('pages')->setOutputFormatting(true);

Now it show the fields but without the template format and images.

Why can this be?

Link to comment
Share on other sites

I would guess that you're assets css and images arent loading because you installed PW in a subdirectory. When you include PW into codeigniter controller the page render output the markup but the paths are screwed. You need to either install PW in the root same as application and system (in case of codeigniter) but that may create problems, or leave it in a subdirectory and somehow fix the paths with htaccess vodoo. I don't really know the answer and what would be best in this case.

Link to comment
Share on other sites

Thank you very much for yours answers. I´ve found that to display the fields I have to include them in the template file. I have given the format I wanted and put the fields in this file, but i have a new question: if I do all this in the template file, what use is to resize the fields and their order in the template?

Thanks!!

Link to comment
Share on other sites

if I do all this in the template file, what use is to resize the fields and their order in the template?

This is purely for controlling the presentation in the admin side. It really doesn't mean much on the front-end of your site, unless you iterate the $page object (in which case the fields will follow the same order).

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...