adrianmak Posted November 26, 2015 Share 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 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted November 26, 2015 Share 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? Link to comment Share on other sites More sharing options...
bernhard Posted November 26, 2015 Share 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 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted November 26, 2015 Share 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 Link to comment Share on other sites More sharing options...
Sradesign Posted November 26, 2015 Share 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. Link to comment Share on other sites More sharing options...
adrianmak Posted November 27, 2015 Author Share 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. Link to comment Share on other sites More sharing options...
Juergen Posted November 27, 2015 Share 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 Link to comment Share on other sites More sharing options...
pwired Posted November 27, 2015 Share 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/ Link to comment Share on other sites More sharing options...
adrianmak Posted November 29, 2015 Author Share 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. Link to comment Share on other sites More sharing options...
Robin S Posted November 30, 2015 Share 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 Link to comment Share on other sites More sharing options...
adrianmak Posted January 23, 2016 Author Share 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) Link to comment Share on other sites More sharing options...
BitPoet Posted January 23, 2016 Share Posted January 23, 2016 Your module is missing public static function getModuleInfo() { return array( /* title, version, summary and autoload values*/ ) }; Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 23, 2016 Share 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. Link to comment Share on other sites More sharing options...
adrianmak Posted January 23, 2016 Author Share 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 ); } Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 23, 2016 Share 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. Link to comment Share on other sites More sharing options...
BitPoet Posted January 23, 2016 Share Posted January 23, 2016 Do file and class names match up? Link to comment Share on other sites More sharing options...
Martijn Geerts Posted January 23, 2016 Share Posted January 23, 2016 And does the file ends with the .module extension ? Link to comment Share on other sites More sharing options...
adrianmak Posted January 23, 2016 Author Share 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. Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 23, 2016 Share 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 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted January 23, 2016 Share 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.... :-) Link to comment Share on other sites More sharing options...
adrianmak Posted January 23, 2016 Author Share 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 ? Link to comment Share on other sites More sharing options...
Martijn Geerts Posted January 23, 2016 Share Posted January 23, 2016 Three underscores make them hookable. 2 Link to comment Share on other sites More sharing options...
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