Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/09/2012 in all areas

  1. ProcessWire doesn't allow direct execution of PHP files in its /site/templates/ directory for security. So what you'd want to do is place your ajax PHP file somewhere else, like in the site root or under some other directory that you've created. Then include ProcessWire's /index.php to bootstrap it: /somefile.php <?php include('./index.php'); // bootstrap ProcessWire if(wire('config')->ajax) echo json_encode("Hello"); When you bootstrap ProcessWire, it'll work the same as it would from your template file, except that you have to access the API variables through the wire() function, i.e. wire('pages'), wire('config'), etc. More here: http://processwire.com/api/include/
    1 point
  2. wortell, welcome to the forums. That is just an css issue with demo site & comments that has been there since beginning. Don't remember exact fix there, but probably changing .CommentForm_text clear: both to clear: left. Or then adding float: left.
    1 point
  3. I agree with Robert about it and better now than later when there is a lot more watchers. I had troubles finding processwire in github because of the P21 name.
    1 point
  4. I think we can automate the field creation part relatively easily. My plan was to add an Export/Import option to Admin > Setup > Fields, and it would basically export a JSON profile of all the fields you selected. Then you could paste that profile into another site into the "import" textarea, and it would create all the fields. The same thing could probably be done at the template level too. The idea you mentioned of a module is also a good one, though I'd probably be inclined to do the export/import described above instead. But here's how you'd go about doing the module if you wanted to. The module would exists to add the fields and templates needed for news. When you click "install" on that module, it would create the fields and templates automatically just with API calls. For example, here's how your module code might do it in it's ___install() method: <?php public function ___install() { $summary = new Field(); $summary->type = $this->modules->get("FieldtypeTextarea"); $summary->rows = 3; $summary->name = "summary"; $summary->label = "Summarize this news item in 1 paragraph"; $summary->save(); $datetime = new Field(); $datetime->type = $this->modules->get("FieldtypeDatetime"); $datetime->name = "datetime"; $datetime->label = "Enter a date"; $datetime->dateOutputFormat = "m/d/y"; $datetime->dateInputFormat = "m/d/y"; $datetime->defaultToday = 1; $datetime->save(); $fieldgroup = new Fieldgroup(); $fieldgroup->name = "news"; $fieldgroup->add($this->fields->get("title")); $fieldgroup->add($summary); $fieldgroup->add($datetime); $fieldgroup->save(); // copy your default news.php template to /site/templates/, assuming your server will let you... copy($this->config->paths->YourModuleName . "news.php", $this->config->paths->templates . "news.php"); $template = new Template(); $template->name = "news"; $template->fieldgroup = $fieldgroup; $template->save(); } Because we don't have the documentation complete to the level of detail of individual fieldtypes, you'd currently have to look at what was configurable with each field. The simplest way to do this is probably to view the source when editing that field in the Fields editor, and looking at what configuration options are available under the "Fieldtype Settings" and "Inputfield Settings". Or just ask me. You might have your module add a hook or two, like PageArray::renderNewsItems() or something like that, if it was helpful to do so. <?php public function init() { $this->addHook("PageArray::renderNewsItems", $this, "renderNewsItems"); } public function rnederNewsItems(HookEvent $event) { $pageArray = $event->object; $out = "\n<ul class='nav'>"; foreach($pageArray as $page) { $out .= "\n\t<li><a href='{$page->url}'>{$page->title}</a> {$page->datetime} {$page->summary}</li>"; } $out .= "\n</ul>"; $event->return = $out; }
    1 point
×
×
  • Create New...