Jump to content

php

Members
  • Posts

    2
  • Joined

  • Last visited

php's Achievements

Newbie

Newbie (2/6)

1

Reputation

  1. Thank you both, this is exactly what I needed. @Sephiroth is your code PHP 7? My IDE didn't like it, but the method worked. I have learned something useful!
  2. Hello, I've been using PHP in an amateurish way for a little while, never really gotten my head around classes etc, but I wrote one for a basic site. I want to make several instances of a site, and link them all to the same Processwire install. So I'm loading Processwire like so in index.php: require('/home/centralsite/public_html/wire/core/ProcessWire.php'); $site = new \ProcessWire\ProcessWire('/home/centralsite/public_html/site/', 'http://example.com'); Works fine Then I'm loading my class include "submissions.class.php"; $submissions = new Submissions; My class does a variety of things <?php class Submissions { private function fields($id=1015) { // load some cms fields } function insert($data) { // foobar } function validate($value,$type) { // foobar } } These functions (redacted) all work fine but... now lets say I want to use some fields etc from my Processwire install inside my class, how do I do it? Eg, if inside $submissions->insert(), I want to get something from $site->pages() or similar. I tried putting it as a method at the top of my class, and then loading it with $this->connect(); however, if I try to do that more than once, I get errors for redefining a class. So, I think I need to extend the Processwire class somehow?
×
×
  • Create New...