adrianmak Posted November 26, 2015 Posted November 26, 2015 Instead of ordinary CMS function, I would like to add a guestbook function on a pw's website. I will create a front-end public form, for users to submit comments/messages Messages are not open to public. To read users' messages, it required to login to pw's backend. It easy to use pw's core page api (under a specific page) to store users submitted messages. However in the guestbook scenario, it is not user friendly in to ordinary page tree UI, to show all submitted messages. I would like the UI looks like, when clicking the page, it will presented in a table view with a pages
Ivan Gretsky Posted November 26, 2015 Posted November 26, 2015 Sorry, but I could not understand what you are questioning about. Could you please try to rephrase and be more specific?
bernhard Posted November 26, 2015 Posted November 26, 2015 sounds like a job for listerpro... just choose what fields to display and you're done. admincustomfiles could also be helpful 3
Ivan Gretsky Posted November 26, 2015 Posted November 26, 2015 Ahh! Got it! You need an admin interface to easilly manage those guestbook submissions. 1) BernhardB's listerpro suggestion is what you want to go for if you have the option to use this paid module. It is really powerfull. 2) You could build a process module to list all guestbook submission for free, but you need to get your hands dirty with code . You can take a look at something like this for an inspiration: class GuestBook extends Process { public function init() { parent::init(); // always remember to call the parent init } public function execute() { $out = ''; $table = $this->modules->get("MarkupAdminDataTable"); // Table header $table->headerRow( ["Name of submission", "By whom...", ...] ); // Selector to get all your guestbook submissions $listing = $this->pages->find("..."); foreach ($listing as $page) { $data = array( // A td with the link to edit the page (you need to change the ... part) $page->title => $this->config->urls->admin . ".../edit/?id=" . $page->id, $page->created_by, ... ); $table->row($data); } $out .= $table->render(); $pagination = $listing->renderPager(); $out .= $pagination; return $out; } public function executeEdit() { // Write code to edit submission } // ... } 6
Sradesign Posted November 26, 2015 Posted November 26, 2015 you can use datatables and a bit of coding and easily achieve what you want if you want I will make a sample for you.
adrianmak Posted November 27, 2015 Author Posted November 27, 2015 you can use datatables and a bit of coding and easily achieve what you want if you want I will make a sample for you. I'm appreciated if you could show a sample. Actually, I am thinking of, instead of using pw's page api, could i use something like pw's raw database api (exist?) to insert and read a db table. The submitted messages on the page tree is not necessary to show to back-end.
Juergen Posted November 27, 2015 Posted November 27, 2015 I dont know what you exactly need in your guestbook but why dont you use the comment field as a guestbook? You can style it in the way you want with overrides. 1
pwired Posted November 27, 2015 Posted November 27, 2015 I dont know what you exactly need in your guestbook but why dont you use the comment field as a guestbook? You can style it in the way you want with overrides. What is so special about the comment field in this matter ? You can pull the contents of any field and css style it through the html thags that surround the the echoed field. Edit: Ah I see now, I posted too early. https://processwire.com/api/fieldtypes/comments/
adrianmak Posted November 29, 2015 Author Posted November 29, 2015 I dont know what you exactly need in your guestbook but why dont you use the comment field as a guestbook? You can style it in the way you want with overrides. I think the name guestbook, which is used in a client's old website (he wanted to revamp the website). After explained by client, the functionality he wanted, is a enquiry form. As I said from OP, the form is open for public to ask information about product. Instead of submitting the form data to a designate email address, the form data will store in database for admin to read.
Robin S Posted November 30, 2015 Posted November 30, 2015 As I said from OP, the form is open for public to ask information about product. Instead of submitting the form data to a designate email address, the form data will store in database for admin to read. Form Builder has this functionality. Form submissions can be displayed in a table in the PW admin or saved as pages. 1
adrianmak Posted January 23, 2016 Author Posted January 23, 2016 I'm now heading to writing the module For simplicity purposes, just display a text class GuestBook extends Process { public function init() { parent::init(); } public function execute() { $out = ''; $out = "Guestbook back-end"; return $out; } public function executeEdit() { // Write code to edit submission } // ... } I went to back-end to install it and pw returned Error: Class 'GuestBook' not found (line 407 of /var/www/html/pw272/wire/core/Modules.php)
BitPoet Posted January 23, 2016 Posted January 23, 2016 Your module is missing public static function getModuleInfo() { return array( /* title, version, summary and autoload values*/ ) };
LostKobrakai Posted January 23, 2016 Posted January 23, 2016 It depends, getModuleInfo() it not required anymore as the config can also be in a separate file. But somewhere there needs to be a config.
adrianmak Posted January 23, 2016 Author Posted January 23, 2016 Your module is missing public static function getModuleInfo() { return array( /* title, version, summary and autoload values*/ ) }; It's is not working. public static function getModuleInfo() { return array( 'title' => 'GuestBook', 'version' => 2, 'summary' => 'Manage Guestbook submission.', 'autoload' => true ); }
LostKobrakai Posted January 23, 2016 Posted January 23, 2016 ProcessModules shouldn't be autoloaded, which means run at every possible request, but that shouldn't be the issue why it's not working.
Martijn Geerts Posted January 23, 2016 Posted January 23, 2016 And does the file ends with the .module extension ?
adrianmak Posted January 23, 2016 Author Posted January 23, 2016 I deleted the old file and create a new one. Works now. By the way, when module installation, it should add a page in under the "Admin" page automatically. I added two method to call the parent install and uninstall method public function install() { return parent::___install(); } public function uninstall() { return parent::___uninstall(); } But no page is added under 'Admin' page.
LostKobrakai Posted January 23, 2016 Posted January 23, 2016 The automatic page creation must be setup in the module config, otherwise the module cannot know which page it should create where. 'page' => array( 'name' => 'guest-book', 'parent' => '', 'title' => 'Guest Book' ) 1
Martijn Geerts Posted January 23, 2016 Posted January 23, 2016 (edited) You have something like this: ? public static function getModuleInfo() { return array( 'title' => 'Your title', 'summary' => 'What you want to say.', 'version' => '0.0.7', 'author' => 'adrianmak', // Do you have this ? 'page' => array( 'name' => 'yourname', 'parent' => 'setup', 'title' => 'Your title', ), ); } BTW, When you don't do anything in public function install() or uninstall, you don't need to use them... Edited January 23, 2016 by Martijn Geerts Damn LostKobrakai, he's way to quick.... :-)
adrianmak Posted January 23, 2016 Author Posted January 23, 2016 Understood. For the purpose of showing up an module navigation in the pw top admin menu, just put a page array as shown in the above post, pw will create it automatically. The install and uninstall method is not necessary in this case. By the way, I found some other module declare execute method in public function ___execute() { } what is the different with or without three underscore prefix ?
Martijn Geerts Posted January 23, 2016 Posted January 23, 2016 Three underscores make them hookable. 2
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now