Jump to content


Photo

Included in another script


  • Please log in to reply
13 replies to this topic

#1 Mike

Mike

    Jr. Member

  • Members
  • PipPip
  • 11 posts
  • 1

Posted 20 April 2012 - 04:14 AM

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!

#2 formmailer

formmailer

    Sr. Member

  • Members
  • PipPipPipPip
  • 245 posts
  • 28

  • LocationHudiksvall, Sweden (but originally from The Netherlands)

Posted 20 April 2012 - 05:13 AM

Hi Mike,

Welcome to the forums.
What are you trying to include and in what script are you trying to include it? Can you give a code example?

/Jasper

#3 Mike

Mike

    Jr. Member

  • Members
  • PipPip
  • 11 posts
  • 1

Posted 23 April 2012 - 03:00 AM

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!

#4 ryan

ryan

    Hero Member

  • Administrators
  • 5,753 posts
  • 3102

  • LocationAtlanta, GA

Posted 23 April 2012 - 12:03 PM

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().

#5 Mike

Mike

    Jr. Member

  • Members
  • PipPip
  • 11 posts
  • 1

Posted 24 April 2012 - 02:36 AM

Thanks Ryan, but my most inmediate problem is another.

I created a template and I created a page with this, but this does not show the fields.

Why can this be?
Thanks!

#6 ryan

ryan

    Hero Member

  • Administrators
  • 5,753 posts
  • 3102

  • LocationAtlanta, GA

Posted 24 April 2012 - 09:20 AM

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.

#7 Mike

Mike

    Jr. Member

  • Members
  • PipPip
  • 11 posts
  • 1

Posted 25 April 2012 - 07:22 AM

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!

#8 ryan

ryan

    Hero Member

  • Administrators
  • 5,753 posts
  • 3102

  • LocationAtlanta, GA

Posted 25 April 2012 - 11:30 AM

You can access any of the $pages fields like: $mypage->title. If you want to render the entire page and echo it to the user, you can do this:

echo $mypage->render();


#9 Mike

Mike

    Jr. Member

  • Members
  • PipPip
  • 11 posts
  • 1

Posted 26 April 2012 - 03:23 AM

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?

#10 ryan

ryan

    Hero Member

  • Administrators
  • 5,753 posts
  • 3102

  • LocationAtlanta, GA

Posted 26 April 2012 - 03:56 PM

Now it show the fields but without the template format and images.
Why can this be?


I'm not sure I understand. Can you post a screenshot of the output that you get?

#11 Soma

Soma

    Hero Member

  • Moderators
  • 3,183 posts
  • 1733

  • LocationSH, Switzerland

Posted 26 April 2012 - 04:52 PM

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.

@somartist | modules created | support me, flattr my work flattr.com


#12 Mike

Mike

    Jr. Member

  • Members
  • PipPip
  • 11 posts
  • 1

Posted 03 May 2012 - 03:59 AM

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!!

#13 ryan

ryan

    Hero Member

  • Administrators
  • 5,753 posts
  • 3102

  • LocationAtlanta, GA

Posted 03 May 2012 - 10:55 AM

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).

#14 Mike

Mike

    Jr. Member

  • Members
  • PipPip
  • 11 posts
  • 1

Posted 04 May 2012 - 03:45 AM

Thank you for your attention and patience Ryan. I think I getting control ProcessWire ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users