Jump to content
SIERRA

Core php page inside the processwire source

Recommended Posts

Hi,

If we create a 'Page' inside processwire we can use the code like '$alertspage=$pages->get(id);' to get the page id etc.  But if I create a core php page inside the processwire source (without using PW template), do I have the possibility to access the processwire code like this. If yes, then could you please suggest how.

Thanks

Share this post


Link to post
Share on other sites

Yes, this is called bootstrapping, see the documentation. Basically, you only need to include ProcessWire's index.php, then you can use the API as usual. The only difference is that you won't have access to the $page variable, since it's not a regular ProcessWire page request, so ProcessWire can't associate a particular page with it.

  • Like 4

Share this post


Link to post
Share on other sites

Thanks. Hope I can access the configured repeater items inside process wire in my core PHP file. I will check the references 

Share this post


Link to post
Share on other sites

Absolutely you can! You just need to get the page the repeater items are on, then you can access the repeater items on it. Based on your code above it should be simple:

$id = 1234; // replace with desired page ID
$alertspage = $pages->get(id);

// replace "alerts" with your repeater field name
foreach ($alertspage->alerts as $alert) {
	// do something with the repeater items ...
}

 

  • Like 2

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...