Jump to content

Search the Community

Showing results for tags 'custom'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. Hello all, So me being a noob can't figure out how can I use $pages->get or find in my custom function. function printTitle($page_id){ echo "Title of the page is ".$pages->get("id={$page_id}"); } Above code is giving me error : Error: Call to a member function get() on a non-object From what I've read probably, I should be using $wire('pages')->get. But this gives following error: Error: Function name must be a string Removing $ from wire solves above error but it doesn't print anything. Any help would be very much appreciated. Thanks a lot.
  2. I am looking to create a multiselect field that allows a user to select some PicasaWebAlbums on the admin side of PW. I know how to get the PicasaWebAlbums list and all, but it requires PHP. I also know how to make a multiselect field the Page input type and defining which parent holds the select options, etc. What I do not know is how I can create a custom multiselect field that is generated via PHP. For example: I have a list of albums from PHP (these are not actually what I have but you get the point): - id: 1000, title: Album 1000 - id: 1004, title: Album 1004 - id: 1008, title: Album 1008 - id: 1005, title: Album 1005 - id: 1003, title: Album 1003 How do I make a multiselect field where the options are: <option value="1000">Album 1000</option> ... etc ... Is this possible? Do I have to make a module? Point me in the right direction
  3. The concept A custom table module process (requires Jquery Datatables module by @soma) with configuration. Features: - Custom selector to find the pages. - Custom fields in columns. - Custom fields search. - Set the number of columns. - Create, View, edit, publish/unpublish pages. I´m working on it. Please correct my mistakes is my first processwire´s module have mercy Screenshots: The code: <?php /** * Administrador de Noticias * * Luis Santiago (blad) 2014 * ProcessWire 2.x * Copyright (C) 2012 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://processwire.com */ class AdminCustomTable extends Process implements Module, ConfigurableModule { const adminPageName = 'AdminTable'; public static function getModuleInfo() { return array( 'title' => 'AdminCustomTable', 'summary' => 'Fully customizable administration table', 'version' => 110, 'permanent' => false, 'permission' => 'AdministrationTable', 'requires' => array("JqueryDataTables") ); } public function __construct() { $this->idparentnews = 'parent=1, include=all'; $this->campo1 = 'title'; $this->campo2 = 'body'; } public static function getModuleConfigInputfields(array $data) { $inputfields = new InputfieldWrapper(); $field = wire('modules')->get('InputfieldText'); $field->name = 'idparentnews'; $field->label = "Custom selector to find pages"; //$field->label = "Selector para encontrar las noticias"; //$field->notes = __('Selector para conseguir las noticias ejemplo: parent=1018, include=all .Se recomienda usar include=all para ver todas las páginas'); $field->notes = __('This selector will be passed to a $pages->find("your selector") Example: parent=1018, template=product, sort=name, include=all .Use include=all for publish/unpublish these pages.'); if(isset($data['idparentnews'])) $field->value = $data['idparentnews']; $inputfields->add($field); $field = wire('modules')->get('InputfieldText'); $field->name = 'campo1'; $field->label = "Custom field for first column"; //$field->label = "Selector para encontrar las noticias"; //$field->notes = __('Selector para conseguir las noticias ejemplo: parent=1018, include=all .Se recomienda usar include=all para ver todas las páginas'); $field->notes = __('Example: title'); if(isset($data['campo1'])) $field->value = $data['campo1']; $inputfields->add($field); $field = wire('modules')->get('InputfieldText'); $field->name = 'campo2'; $field->label = "Custom field for second column"; //$field->label = "Selector para encontrar las noticias"; //$field->notes = __('Selector para conseguir las noticias ejemplo: parent=1018, include=all .Se recomienda usar include=all para ver todas las páginas'); $field->notes = __('Example: body'); if(isset($data['campo2'])) $field->value = $data['campo2']; $inputfields->add($field); return $inputfields; } /** * Inicio del módulo * */ public function init() { $this->config->scripts->add($this->config->urls->AdminCustomTable . 'prog.js'); // $this->config->styles->add($this->config->urls->AdminCustomTable . 'style.css'); $this->modules->JqueryDataTables; } /** * Ejecución del módulo * */ public function ___execute() { $this->modules->get("JqueryFancybox"); $selector = $this->idparentnews; $campo1 = $this->campo1; $campo2 = $this->campo2; $noticias = wire('pages')->find("{$selector}"); $out = "<table id='mitabla' style='margin-top:20px; margin-bottom:20px;'> <thead> <tr> <th style='width:40%'>{$noticias->fields->$campo1->label}</th> <th style='width:50%'>{$noticias->fields->$campo2->label}</th> <th class='sin-orden' style='width:10%'>Actions</th> </tr> </thead> <tbody> "; $adminUrl = $this->config->urls->admin; $noticias->fields->title->label; /** * Nos deja buscar el id de la página * */ // if( $this->input->get->sSearch ) { // $q = $this->sanitizer->text($this->input->get->sSearch); // if (is_numeric($q)) { // $selector .= "id=$q,"; // } else { // $selector .= "title|body%=$q,"; // } // } /** * buscamos el selector * */ foreach($noticias as $noticia) { $out .= " <tr> <td>{$noticia->{$campo1}}</td> <td>{$noticia->{$campo2}}</td> <td> <a class='fancybox-iframe' href='{$adminUrl}page/edit/?id={$noticia->id}&modal=1'><i class='fa fa-edit'></i></a></br> <a href='{$adminUrl}page/delete/?id={$noticia->id}'><i class='fa fa-times'></i></a></br>" ; /** * botón de publicar-despublicar * */ if ($noticia->is(Page::statusUnpublished)) { $out .= "<i style='color:red' class='fa fa-square-o'></i>"; } else { $out .= "<i style='color:green' class='fa fa-check-square-o'></i>"; } $out .= "</td></tr>" ; } $out .= "</tbody></table>" ; return $out; } /** * Instalación * */ public function ___install() { $admin = $this->pages->get($this->config->adminRootPageID); $parent = $admin; $page = new Page(); $page->parent = $parent; $page->template = $this->templates->get('admin'); $page->name = "AdminCustomTable"; $page->title = "AdminCustomTable"; $page->process = $this; $page->save(); $this->message("You have installed AdminCustomTable"); if (!$this->permissions->get('AdministrationTable')->id) { $permission = $this->permissions->add('AdministrationTable'); $permission->title = 'AdminCustomTable permission.'; $permission->save(); } } /** * Desinstalación * */ public function ___uninstall() { $page = $this->pages->get('template=admin, name=AdminCustomTable'); $page->delete(); $permission = $this->permissions->get('AdministrationTable'); $permission->delete(); } }
  4. Based on my Previous thread: https://processwire.com/talk/topic/7194-templatelist-inside-module-configuration/ here is an automatic child creater if you need on creation of a parent element a bunch of Child Elements. what also works: multiple diffrent childs on same parent caution: sadly what also works: first entry: parent_id = 47 child_id = 13 child_name = something child_numbers = 1 second entry: parent_id = 13 child_id = 47 ... ... this should afaik (not tested) kill your System by having a infinite Loop. because (first entry creates a child which call second entry which would then call first entry and so on). <?php /** * Created by PhpStorm. * User: Kielbasa * Date: 04.08.14 * Time: 10:09 */ class CustomChildCreater extends Process { public static function getModuleInfo() { return array( 'title' => 'CustomChildCreater', 'version' => 100, 'summary' => 'Child creator for Pages with Specific Parent', 'href' => '', 'singular' => true, 'autoload' => true, ); } public function ___execute() { $this->setFuel('processHeadline', 'Child Creater'); $table = $this->modules->get("MarkupAdminDataTable"); $table->setEncodeEntities(false); $table->headerRow(array('Edit','Parent Template', 'Child Template','Name of new Childs (childname+{n})', '{n} - Childs', 'Delete')); $result = $this->db->query("SELECT * FROM {$this->className} ORDER BY parent_template"); while($row = $result->fetch_assoc()) { // output in table rows with edit link and delete checkbox? $table->row(array( 'edit' => 'edit/?id='.$row['id'], $this->templates->get($row['parent_template'])->name , $this->templates->get($row['child_template'])->name, $row['child_name'], $row['child_numbers'], "<input type='checkbox' name='delete[]' value='$row[id]' />" )); } $button = $this->modules->get("InputfieldButton"); $button->type = 'submit'; $button->id = 'submit_delete'; $button->value = 'Remove selected sources'; $table->action(array('Add source' => 'add/')); // Is there clean way to add button to right side? return "<form action='./delete/' method='post'>" .$table->render() . $button->render() . "</form>"; } public function ___executeAdd() { $this->fuel->breadcrumbs->add(new Breadcrumb('../', 'Child Creater')); $this->setFuel('processHeadline', "new Instance"); $form = $this->modules->get("InputfieldForm"); $form->method = 'post'; $form->action = '../save/'; //--Parent Template $field = wire('modules')->get('InputfieldSelect'); $field->attr('name', 'parent_template'); $field->label = __('Parent Template'); foreach(wire('templates') as $template){ $field->addOption($template->id, $template->name); } $form->add($field); //--Child Template $field = wire('modules')->get('InputfieldSelect'); $field->attr('name', 'child_template'); $field->label = __('Child Template'); foreach(wire('templates') as $template){ $field->addOption($template->id, $template->name); } $form->add($field); //--Child Name $field = wire('modules')->get('InputfieldText'); $field->attr('name', 'child_name'); $field->label = __('Child Name'); $form->add($field); //--Children to Create $field = wire('modules')->get('InputfieldInteger'); $field->attr('name', 'child_number'); $field->label = __('Childs to Create'); $form->add($field); $field = $this->modules->get("InputfieldButton"); $field->type = 'submit'; $field->value = 'Create'; $form->add($field); return $form->render(); } public function ___executeSave() { $parent_id = (int) $this->input->post->parent_template; $child_id = (int) $this->input->post->child_template; $child_name = $this->input->post->child_name; $child_numbers = (int) $this->input->post->child_number; //no i am not allowing you to kill your system if($parent_id != $child_id){ $sql = "INSERT INTO {$this->className} SET parent_template = '$parent_id', child_template = '$child_id', child_name = '$child_name', child_numbers = '$child_numbers' ON DUPLICATE KEY UPDATE id = id;"; $this->db->query($sql); $this->message("Save Successful"); $this->session->redirect("../"); } $this->message("Parent and Child should not be the same!"); $this->session->redirect("../"); } public function ___executeEdit(){ if(!isset($_GET['id'])){ $this->session->redirect("../"); } $id = (int) $_GET['id']; $result = $this->db->query("SELECT * FROM {$this->className} WHERE id=$id"); $data = $result->fetch_array(); $form = $this->modules->get("InputfieldForm"); $form->method = 'post'; $form->action = '../update/'; $field = $this->modules->get("InputfieldHidden"); $field->name = 'id'; $field->value = $id; $form->add($field); //--Parent Template $field = wire('modules')->get('InputfieldSelect'); $field->attr('name', 'parent_template'); $field->label = __('Parent Template'); foreach(wire('templates') as $template){ $field->addOption($template->id, $template->name); } $field->value = $data['parent_template']; $form->add($field); //--Child Template $field = wire('modules')->get('InputfieldSelect'); $field->attr('name', 'child_template'); $field->label = __('Child Template'); foreach(wire('templates') as $template){ $field->addOption($template->id, $template->name); } $field->value = $data['child_template']; $form->add($field); //--Child Name $field = wire('modules')->get('InputfieldText'); $field->attr('name', 'child_name'); $field->label = __('Child Name'); $field->value = $data['child_name']; $form->add($field); //--Children to Create $field = wire('modules')->get('InputfieldInteger'); $field->attr('name', 'child_number'); $field->value = $data['child_numbers']; $field->label = __('Childs to Create'); $form->add($field); $field = $this->modules->get("InputfieldButton"); $field->type = 'submit'; $field->value = 'Save'; $form->add($field); return $form->render(); } public function ___executeUpdate(){ $this->fuel->breadcrumbs->add(new Breadcrumb('../', 'Data imports')); $id = $this->input->post->id; $parent_id = (int) $this->input->post->parent_template; $child_id = (int) $this->input->post->child_template; $child_name = $this->input->post->child_name; $child_numbers = (int) $this->input->post->child_number; //no i am not allowing you to kill your system if($parent_id != $child_id){ $this->db->query("UPDATE {$this->className} SET parent_template = '$parent_id', child_template = '$child_id', child_name = '$child_name', child_numbers = '$child_numbers' WHERE id=$id"); $this->message("Update Successful"); $this->session->redirect("../"); } $this->message("Parent and Child should not be the same!"); $this->session->redirect("../"); } public function ___executeDelete() { $count = 0; if(!is_array($this->input->post->delete) || empty($this->input->post->delete)) { $this->message("Nothing to delete"); $this->session->redirect("../"); // back to list } foreach($this->input->post->delete as $id) { $id = (int) $id; $this->db->query("DELETE FROM {$this->className} WHERE id=$id"); $count++; } $this->message("Deleted " . $count . " data sources"); $this->session->redirect("../"); // back to list } public function ___install() { parent::___install(); $p = new Page(); $p->template = $this->templates->get("admin"); $p->parent = $this->pages->get("template=admin, name=setup"); $p->title = 'Child Creater'; $p->name = 'child-creater'; $p->process = $this; $p->save(); $sql = <<< _END CREATE TABLE {$this->className} ( id int unsigned NOT NULL auto_increment, parent_template int unsigned NOT NULL, child_template int unsigned NOT NULL, child_name varchar(255) NOT NULL, child_numbers int unsigned NOT NULL, PRIMARY KEY(id) ) ENGINE = MYISAM; _END; $this->db->query($sql); } public function ___uninstall() { $p = $this->pages->get('template=admin, name=child-creater'); $p->delete(); $this->db->query("DROP TABLE {$this->className}"); } public function init() { parent::init(); // add a hook after the $pages->save, to issue a notice every time a page is saved $this->pages->addHookAfter('added', $this, 'createChildren'); } public function createChildren($event){ $page = $event->arguments[0]; $query = $this->db->query("SELECT * FROM {$this->className};"); //foreach child creater object foreach($query as $cco){ $t = $cco['parent_template']; $ct = $cco['child_template']; $cn = $cco['child_name']; $ci = (int) $cco['child_numbers']; $c = ''; //will be used as new Page if($t == $page->template->id){ if($ci > 0){ for($i=1;$i <= $ci;$i++){ $c = new Page(); $c->template = $ct; $c->parent = $page; // set the parent $c->name = $cn.$i; // give it a name used in the url for the page $c->title = $c->name; $c->gsv_tab_position = $i; $c->save(); } } } } } } Tell me your thoughts
  5. Hi all, Let's say I want a landing page for a process module. If I wanted a form on the landing page - InputfieldForm comes to mind If I wanted a table - MarkupAdminDataTable However, on that page, I don't want a form nor a table. I just want my plain HTML to be rendered. I have no need for Inputfields on this page. Next, I look at InputfieldWrapper - But the docs say: Not my intended question, but I don't get this bit "but you can set a value...". How? I tried different stuff without success. Final up (to the best of my knowledge) is InputfieldMarkup. This code does work: $test = $this->modules->get('InputfieldMarkup'); $test->value = "<p>My test HTML output</p>"; //return $test->renderValue();//doesn't work. Markup not output return $test->render();//works fine I get my HTML output in the right place in my module landing page in the PW Admin without any extraneous markup. <div id="content" class="content"> <div class="container"> <p>My test HTML output</p> </div> </div> <!--/#content--> But is this the way to go? The name of the class sort of suggests that it should be used with Inputfields. If I try to add my HTML independent of these methods, the markup is not output in the right place in my module landing page in the PW admin, i.e. between the <div class="container"></div>. It will be thrown to the top of the page, somewhere weird like before the <body> tag. So, am I on the right track here or there is a "more appropriate" way? By the way, I tried to use renderValue() but it doesn't output anything? What's the use case for this method? The docs say: I have studied some other modules but have not seen something similar to this sort of landing page. Thanks.
  6. Hi there, Is it possible to make an Image Field store the images on a custom folder? Because my images are being stored in a folder called '1012', how can I change this. Thanks
  7. I'm a Toronto-based web designer and developer. Tinacious Design is my ProcessWire-powered website and it includes my web design and development portfolio and information about my services. See the website here: TinaciousDesign.com The back-end uses a modified version of the Moderna admin theme. I also posted a video on Vimeo showing the behind-the-scenes process of adding a new portfolio item.
  8. Although not frequent, and usually not for very long, databases will experience problems and just not be able to be connected to. An error message of just "Unable to complete this request due to an error. Error has been logged." just doesn't seem too friendly to visitors. Perhaps I just haven't seen this (or discovered how to do it), but if it isn't currently an option (or a hook) for this, it'd be a welcomed thing. (If there is a way to do this, I apologize...it's sometimes hard to come up with the proper search terms to find results.)
  9. Hello everyone, I'm trying to make a custom menu where I need to create a placeholder (drop down) for specific pages but I would like to make this dynamic, so I wouldn't need to edit the navigation file everytime there's a change. Basically something like this: Home Page A Page B Page C Page D Page E Page F Page G To this: Home Page A Page B Placeholder (not a real page) |----Page C |----Page D |----Page E |----Page F Page G I can acces the specific pages through a hidden field, I check for its existence. I know it's possible to create a new Page dynamically but can you add children to it without saving it? I could go for recursion but then almost every other page has children but I don't need them to show up in the menu. I may be complicating something but I don't know, so any help is welcomed! Thank you.
×
×
  • Create New...