Jump to content

How to approach this feat in Processwire


qtguru

Recommended Posts

Hi guys am a complete Noob to Processwire and i have spent the past two weeks reading codes and understanding the structure and concept around it. So i am the type of dev who obesseses about architecture structure before getting to work, and i think my mind is broken due to my limited knowledge on PW. So i will expain my goal.

I intend to rebuild http://styljunki.com from Wordpress to Processwire because of two reasons.

1. PW has no templating system meaning no hacks like shortcode or mundane template conventions.

2. Modules dependency meaning i can leverage on existing modules (easily) e.g wire('moduleName')->method this really appeals to me alot

However there are certain tasks i want to achieve.

Concept of Blog vs Pages

There are some contents which are Post and some which are pages, is there some such dinstinction in PW, I know PW manipulates pages and adds fields but what of Blogs which just take entry and nothing special, I tried my hands on the Blog Module on PW 2.5.8 but it threw some errors.

Menu Management

My Client intends to manage menus and from what i have seen ; PW lists all the pages, we were looking for something where we  can simply create menus for the front page and we simply pick those. But if there's a module around I am willing to use/ contribute code if it is neccessary.

Custom Post

In Wordpress you can create a custom post and query that, is there any similar thing to that ?

Unit testing

PHPUnit Testing in WordPress was a big joke, is there any link to unit test processwire while we work

Thanks this are my questions

NOTE:

Also i'd really like to say congrats because, I have spent the 4 years of my life developing with CMS from Joomla,WordPress,ImpressPages and really this is the first time i am really excited about a CMS.

Working with WordPress as a CMS is a pain in the ass, esp for someone used to MVC frameworks like Zend and Yii. I have searched and searched till i came across your site on CMSCritic and Joss Salinger 's post the rocker blogger (rock on) on how easily he could use it despite no coding experience. I intend to contribute in my way. Keep up the good work guys. Love from Nigeria

  • Like 7
Link to comment
Share on other sites

Okay, I will address the Pages issue - I am somewhat famous for it! :)

To start: https://processwire.com/talk/topic/2296-confused-by-pages/

And once you have that out of your system, here is the real info.

Basically, a page in Processwire is just a container for content - nothing more.

So, it could be a:

  • Web Page
  • News Bullitin
  • Block of info
  • Some strange widget
  • An option for a dropdown selector
  • A gallery item
  • A review
  • Something that gets stuffed into something else!
  • A parent of some other group of pages,
  • A child of something

Basically, it is just an item that is created using the criteria of a template.

It does not need to have a template file associated with it - if you are using it as a simple option in a drop down, what would be the point?

Fields from a particular page can be called into another template or page or anything else, either singularly or rendered as a group.

The contents of a page need a template file to be displayed on the site as they are, but not if they are being displayed by something else.

Confused?

The bottom line is don't think of a page as a "page" that you would get in Wordpress - just think of it as a container for data that can be used for anything at all.

This is why Processwire is a TRUE content management system - because all the elements are simply tools to help you manage content, they do not force you to make your content any particular shape.

  • Like 7
Link to comment
Share on other sites

Hi @Sephiroth,
 
Welcome to PW and the forums. I am sure Joss is writing a long post right now to answer your questions :-)...(edit: he just did)
 
About this:
 

I tried my hands on the Blog Module on PW 2.5.8 but it threw some errors.

Can you confirm if you are really talking about the Blog (Site) Profile rather than the Blog Module? if the latter, what errors did you get? The Blog Module works fine for me even in 2.5.9.

PHP Unit Testing: There was something in the works but I don't know the current status - https://processwire.com/talk/topic/2609-tests-for-processwire-core/

Menu Management: There is nothing out-of-the-box that the client themselves can (should?) use. A while back I did a proof-of-concept Menu Builder but never got it finished. However, there are other ways to achieve this. One way is to set up (yes, you guessed it), a 'page' field that you can attach to some template where a client can select pages that he/she wants to appear in a menu. A second similar option is to set up a 'checkbox field' that you attach to the template of pages that can potentially appear in a menu. Every time the client edits such pages they can tick the checkbox to enable (or disable depending on how you code it in your template file) that page to appear (or not appear) in a menu.

Custom Post: Don't use WP so I don't know what this is. Maybe explain a bit more? Edit: OK, just read this:

A custom post type is nothing more than a regular post with a different post_type value in the database. The post type of regular posts is post, pages use page, attachments use attachment and so on. You can now create your own to indicate the type of content created. You could create custom post types for books, movies, reviews, products and so on.

Given Joss' explanation above about pages, I think that answers your question. Really, in PW everything is custom. PW doesn't care what you call them :D. You will probably get a better explanation...

Edited by kongondo
  • Like 3
Link to comment
Share on other sites

On the custom post issue - in ProcessWire there is no need since EVERYTHING is a custom something.

Unlike Wordpress there is no default type of template like an "article."

For a better understanding, I suggest doing a test install with the Blank Profile which is what most use once they get their head round PW. You will see there is only one field created and only a couple of templates. You create your own content types.

Try this tutorial:

http://processwire.com/docs/tutorials/simple-website-tutorials/the-basic-website/

Link to comment
Share on other sites

Wow am so happy about the feedback, hi the name "kongondo" was in the blog module but am gonna look at it again, also yeah you are right i keep thinking about Pages literally rather than the context used in PW. Hopefully am gonna get WordPress style outta my system i will start gradually and research more and update this thread so others can learn from this also. thanks alot.

Link to comment
Share on other sites

Menu Management

My Client intends to manage menus and from what i have seen ; PW lists all the pages, we were looking for something where we  can simply create menus for the front page and we simply pick those. But if there's a module around I am willing to use/ contribute code if it is neccessary.

I almost never use the default menu listing of the page tree; i make a custom page tree somewhere under a "Menus" page and then generate the menus there, as is mentioned by Kongondo above... works like a charm.. if you need help building it, let me know!

  • Like 2
Link to comment
Share on other sites

It makes a lot of sense for the menu to reflect the page tree - your site map makes sense, pages are easy to locate in the back end because they follow the identical structure to the front end and so on.

I think there is an inherent danger if a client pushes and pulls their menu around too much - you can get a lot of broken links and illogical cross linking after a while. So a system where they have to work logically can be a life saver.

  • Like 1
Link to comment
Share on other sites

Menu Management

My Client intends to manage menus and from what i have seen ; PW lists all the pages, we were looking for something where we  can simply create menus for the front page and we simply pick those. But if there's a module around I am willing to use/ contribute code if it is neccessary.

There are usually 2 menu types on most sites. Let me generalise here a bit.

  • You've got the top navigation which tends to be global. It's on every page and usually accompanies the company logo.
  • Then you've got the side navigation which is contextual or based on the section the user is currently within.

I'm assuming you're asking how you your client can pick which links / pages are used on the top navigation?

  1. Create a field called top_navigation or something meaningful to you and your clients
  2. Set it to Type=Page type (Basics Tab)
  3. Make it Multiple Pages (Details Tab)
  4. Assign it PageListMultipleSelect+ win the Input field type (Input tab)
  5. Finally, associate this naviagtion field with a template.

    You can just assign it to the homepage or you could create a new page called Site Settings or Navigation. Just tell your client this is the place to manage their top menu.

Here's a screengrab of how it should look.

post-1166-0-60068400-1416831545_thumb.pn

  • Like 8
Link to comment
Share on other sites

There are usually 2 menu types on most sites. Let me generalise here a bit.

  • You've got the top navigation which tends to be global. It's on every page and usually accompanies the company logo.
  • Then you've got the side navigation which is contextual or based on the section the user is currently within.

I'm assuming you're asking how you your client can pick which links / pages are used on the top navigation?

  1. Create a field called top_navigation or something meaningful to you and your clients
  2. Set it to Type=Page type (Basics Tab)
  3. Make it Multiple Pages (Details Tab)
  4. Assign it PageListMultipleSelect+ win the Input field type (Input tab)
  5. Finally, associate this naviagtion tab with a template. You can just assign it to the homepage or you could create a new page called Site Settings or Navigation. Just tell your client this is the place to manage their top menu.

Here's a screengrab of how it should look.

attachicon.gifnavigation.png

Oh Lord :o this is exactly what i was gaming for, and your explanation is correct. I will sit on it tonight and read the codes after work, it seems i have to research heavily on Fields as that's where the main concept lies around. 

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

Sorry for the late reply, my work and Skyrim takes alot of my time. Thanks all so i started using it fully and went in and out and look at people's code now I understand Processwire better, I don't need a Module to manage menus anymore, like Joss said everything is a Page, with that i simply just get the children of the page and that's it. This is so awesome because i decided to switch from Impresspages (which was switch from Wordpress) to Processwire and it took me a night (few hours) to achieve a lot. Now I am interested in creating modules as a way of support I created plugins,themes for ImpressPages so is there a forum where ideas of modules are thrown I've gone too technical so ideas don't come to me easily anymore. Thanks guys.

Link to comment
Share on other sites

  • 5 weeks later...

Alright guys having spent alot of hours working and reading PW codes, just like Neo i can see how the codes work Everything is connected everything is a page. However I have one issue breaking my mind.

Frontend Administrator ( I will be sincerce am so burnt out i can't think)

I want Something like this

Members ->

     Artist-> list of members go here

     Musicians->list of members go here

I am going to be creating a form to register members and once approved they get accepted into the member page but I prefer not to build another interface just to do this, I'd rather save them then make them hidden pending we delete them or approve them.

So my question is how do i create a frontend admin page for the members to alter their information without having to create a seperate page. I what to know the PW paradigm because remember i almost attempted to build a menu manager till i grasped PW better and figured it was irrelevant to do such. Thanks all

Link to comment
Share on other sites

ok some examples:

https://processwire.com/talk/topic/8556-best-practice-on-frontend-members-site/#entry82726

more:

https://processwire.com/talk/topic/6312-user-field-update-form-security/

and you could use the forms from processwire API to get there:

https://processwire.com/talk/topic/2089-create-simple-forms-using-api/

there is a FormHelper module for the frontend, too:

https://processwire.com/talk/topic/7860-module-formhelper/

and a frontendmodule that is build for the FormHelper:

https://processwire.com/talk/topic/7997-frontendcontentmanager/

so neo please choose the blue or the red one :lol:

Link to comment
Share on other sites

  • 2 weeks later...

I really want to thank you guys all for the patience and time to answering this questions, however sadly I have much In-depth technical questions to ask and I will explain why I am asking all these questions, that way you will get a picture of where am coming from.

I built a WordPress website which is a fashion directory and it is heavily customized, however I have implemented 40% of the features to Processwire but I have some questions which I would ask and give reasons behind them.

1. Is it a Good Practice to create your own Database Schema and not necessarily follow PW architecture of Fields ?

  In our WordPress application, we have a form that accepts application and stores them in a WordPress TableList until the admin activates or rejects them, upon activation I could save them as pages however i don't intend to save the pending applications as pages, will it be Anti-Processwire to display the table in the admin in own way as to using Pages/Fields.

2. PHP Command Line

 We use a Real Cronjob to delegate sending of newsletter to subscribers however as to my research it seems ProcessLazyCron gets triggered upon a visit so my question is, are there any resources/tutorials on running processwire in CLI mode. 

3. Migrating 6gb of Images from WordPress to Processwire 

This is my biggest nightmare even Adrian assists in giving advises on this, We will eventually migrate all of our data however the host is limited in space pending we upgrade. Is it possible for me to explicitly set the source of the image without saving a copy ? I know it sounds wrong but i intend to save the Image Path without the saving images then later move the images to the folder that way i don't make a duplicate for each image.

Our total space is 9GB on our server and our Image count is 6,738 Number of Images it takes likes 6GB the last time i checked.

I want the FieldTypeImage to read the images from a specific folder

Thanks all once again. Will share my experience one of these days because am doing a lot of complicated stuff in Processwire and its pretty fun.

 

Link to comment
Share on other sites

That last update to Migrator that we have been discussing handles your desire to NOT migrate images, but rather point to the original source. If you need to do this until you can upgrade the server and then migrate the images, I am sure it wouldn't be too hard to steal some of the code from Migrator (in the idImagePath() function) to iterate through all the pages, download the images, and edit the links in the RTE fields. Let me know if you need any help with that when the time comes.

Link to comment
Share on other sites

That last update to Migrator that we have been discussing handles your desire to NOT migrate images, but rather point to the original source. If you need to do this until you can upgrade the server and then migrate the images, I am sure it wouldn't be too hard to steal some of the code from Migrator (in the idImagePath() function) to iterate through all the pages, download the images, and edit the links in the RTE fields. Let me know if you need any help with that when the time comes.

Wow for real dude, you just saved me alot of code I was gonna write, I will review the last update and test it out, also is there a forum for ideas of Module am not good in the idea for Module department want to contribute more to processwire. Thanks alot bro

Link to comment
Share on other sites

Wow for real dude, you just saved me alot of code I was gonna write

I didn't have to do much - I really just fixed those issues you were having with the Edit Imported Content option when removing the images field. Also a little code to not rewrite the image tags and links in the RTE field if the images are not actually migrated across (because the images field wasn't included).

is there a forum for ideas of Module am not good in the idea for Module department want to contribute more to processwire.

You have already contributed significantly by adding comments support for MigratorWordpress!

General PW ideas can be posted in the Wishlist board - I think this is likely the best place for module ideas too, but maybe also in the "Module/Plugin Development" sub-board?

Link to comment
Share on other sites

Couple of cents from my end as I ran into similar issues a while back with one of my sites (the custom db and command line use):

What http://processwire.com/api/include/ doesn't portray very well is the ease at which shell scripts handling a multitude of processing (in my specific case the automated processing of order emails to extract the order details) can be integrated by simply calling a php file. Command line php can take additional parameters, such as values extracted in the processing and handle them. Give me a shout if you want more info on that part.

Database wise I've had to include custom tables alongside the pw structure for a variety of reasons. Where possible I tend to avoid adding tables though as part of the reason pw is as fast as it is lies with the way the database is designed and structured. However, where needed using custom tables is dead easy and doesn't impact directly on the way the pw queries behave (unless you overwrite the pw structure of course).

Link to comment
Share on other sites

I really want to thank you guys all for the patience and time to answering this questions, however sadly I have much In-depth technical questions to ask and I will explain why I am asking all these questions, that way you will get a picture of where am coming from.

I built a WordPress website which is a fashion directory and it is heavily customized, however I have implemented 40% of the features to Processwire but I have some questions which I would ask and give reasons behind them.

1. Is it a Good Practice to create your own Database Schema and not necessarily follow PW architecture of Fields ?

  In our WordPress application, we have a form that accepts application and stores them in a WordPress TableList until the admin activates or rejects them, upon activation I could save them as pages however i don't intend to save the pending applications as pages, will it be Anti-Processwire to display the table in the admin in own way as to using Pages/Fields.

2. PHP Command Line

 We use a Real Cronjob to delegate sending of newsletter to subscribers however as to my research it seems ProcessLazyCron gets triggered upon a visit so my question is, are there any resources/tutorials on running processwire in CLI mode. 

3. Migrating 6gb of Images from WordPress to Processwire 

This is my biggest nightmare even Adrian assists in giving advises on this, We will eventually migrate all of our data however the host is limited in space pending we upgrade. Is it possible for me to explicitly set the source of the image without saving a copy ? I know it sounds wrong but i intend to save the Image Path without the saving images then later move the images to the folder that way i don't make a duplicate for each image.

Our total space is 9GB on our server and our Image count is 6,738 Number of Images it takes likes 6GB the last time i checked.

I want the FieldTypeImage to read the images from a specific folder

Thanks all once again. Will share my experience one of these days because am doing a lot of complicated stuff in Processwire and its pretty fun.

 

Thanks for the response all, after further investigation and reading Bootstrap and includes I was able to import all the Members in processwire easily using CLI PHP, however couldn't use WP and PW together in CLI as they had similar function names so a clash ensued.

I am documenting my result for educational purposes incase anyone wants to achieve the same. Our Membership is stored in a seperate table that links to a post. with the script below we are able to import them with freaking ease.

<?php
set_time_limit(0);
/**
 * Created by PhpStorm.
 * User: x64
 * Date: 1/24/15
 * Time: 2:29 PM
 */

    echo "****Welcome to Processwire CommandLine API**** \n";
    echo "****This script will migrate WordPress Membership from Styljunki to Processwire**** \n";

    //Require Processwire
    include_once("../StyljunkiPw/index.php");
    //Connect to WordPress
    // include_once("../WP38/wp-load.php"); // Wordpress API
    try{
    $wpdb = new PDO("mysql:dbname=styljunki_backup;host=localhost", "root", "admin",
    array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"));
     //Fetch All the Data from the Membership Page
       $query="SELECT * FROM  wp_styljunki_registration where approved = '1'";
       $stmt=$wpdb->query($query);
       $stmt->setFetchMode(PDO::FETCH_OBJ);
       while($row=$stmt->fetch()){
           //let's remove the category they belong to
          $Membership=new Page();
          $Membership->template="membership";
          //let's get the type of membership
          $category=smartGetMembers($wpdb,$row->post_id);
          if(is_null($category)){
            //get the default parent
            
            $Membership->parent="/members/";
            
          }
          else{
            $members=$wire->pages->get("/members/".$category);
            echo "Member ID:".$members->id.'\n';
            $Membership->parent_id=$members->id;
          }
          $Membership->name = wire('sanitizer')->pageName($row->fullname);
          $Membership->title = $Membership->name;
          $Membership->of(false);
          //assign all the properties

          foreach ($row as $key => $value) {
             if($key == "id" || $key == "approved" || $key == "time_sent" || $key == "last_modified" || $key == "height" || $key == "old_id"){
                continue;
             }
             $Membership->{$key}=$value;
             
          }
          
          $Membership->save();
          echo "Entry for {$row->fullname} has been imported successfully\n";

          
          

       }
           
    }
    catch(PDOEXception $e){
        echo $e->getMessage();

    }
    echo "Commandline::finshed \n";
    
    function smartGetMembers(PDO $db,$postID){
       $statement=$db->prepare("SELECT * FROM `wp_term_relationships` 
        as tti INNER JOIN wp_term_taxonomy ON tti.`term_taxonomy_id`
        =wp_term_taxonomy.term_taxonomy_id WHERE `object_id` = ?
        ");
       $statement->execute(array($postID));
       $statement->setFetchMode(PDO::FETCH_OBJ);
       while($row=$statement->fetch()){
            $d=sniffMemberType($db,$row);
            if(is_null($d)):
                continue;
            else:
                return $d;
            endif;
       }

       }

    function sniffMemberType(PDO $db,$resultSet){
        $stmt=$db->prepare("Select * from wp_terms where term_id = ?");
        $stmt->execute(array($resultSet->term_id));
        $stmt->setFetchMode(PDO::FETCH_OBJ);
        while($row=$stmt->fetch()){
            switch($row->name){
                case "Stylist":
                case "Designer":
                case "Make-up artist":
                case "Model":
                case "Photographer":
                    return strtolower(str_replace(" ","-",$row->name)."s");
                break;
                
                default:
                    
                break;    
            }
            continue;
        }
    }

Because we have so many datas in wp_options and wp_terms that need exporting also. 

post-2850-0-40552500-1422217684_thumb.pn

Link to comment
Share on other sites

  • 1 month later...

Today got to deal with the part i hate the most (Form Handling) because there are so much scenarios in Forms, Form handling with Wordpress sucks so bad, however in Processwire its somehow limiting however it gives room for expanding so i had an idea. There's no way I would like to create my own validation library so I decided to extend the InputFieldForm to allow some methods

1. setValidator,getValidator

2. setError/getError //already provided

3.get/set Field //already provided

My plan was to override the processInput to trigger the validator for each field and send the error to the respective field which will be pulled in a template. using form in the frontend is just too limiting and haven't seen a way to also have control over my markup, any documentation to assist

Link to comment
Share on other sites

  • 2 weeks later...

Okay got another task I have an admin dashboard created however I want when a user logs in i totally change to a different layout. 

is it possible to Hook into PW and change the template from _main.php to another ? Thanks

Link to comment
Share on other sites

I don't have an overview on what exactly you're using to render the mentioned _main.php. You can either use a if else statement in the _main.php and dependent on that include 2 different php files for the layouts or you need to take a look at the ProcessModule you're using to render it and see if you can change the file by hooking there. Or at least tell us here, what you're using, so we can help there.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...