Jump to content

PW tuts elsewhere on the web


benbyf
 Share

Recommended Posts

Hi!

I'm writing some tutorials for Tuts+ and I'll put some information here when I have it. Love to hear your suggestions, and I think a couple of other people are wirting tutorials there and of course many other places.

  • Like 4
Link to comment
Share on other sites

anyone have any thoughts or examples of tutorials for theme building in PW, just about to write mine as part of a series on envato. Ideally I'm looking to make my tutorial about making a complete theme for a simple website based from PW's site-default.

  • Like 1
Link to comment
Share on other sites

I personally have some struggles with the main concepts

templates, fields and how to use them in different pages.

I remember making a website with a different field for each data, because different labels were needed

then later I discovered that you can assign different labels for each page context.

The approach for templates, fields and pages that I found easier to explain

is like OOP Classes, Properties and Instances.

Template = Class

Field = Property

Page = Instance

Now you can use any UML tool to create a class diagram for a website in Processwire

and explain that to every developer that knows UML.

  • Like 1
Link to comment
Share on other sites

mainly advice on what you'd want to see if you were new to PW theming

I would like to make a suggestion, which combines this topic with those of the cheat sheet and documentation topics, and the blog posts covering filed type definitions.

I would think that someone new to processwire isn't concerned so much as how to design a front-end layout as it is how to use the power of the api as it relates to both the front-end and manipulating the supporting data. I think most people coming to processwire already have a decent grasp of HTML, PHP, etc., but lack an understanding of how to assemble all the excellent tools found within the processwire core to accomplish a desired goal. Based on the recent (past few weeks) forum topics, tutorials could cover menu creation, searching, extracting specific data from one or more pages, defining multi-language interfaces, etc.

As there are many ways to approach a general objective, I would like to see specific procedures that utilize the efficiency of processwire. A great example is this tutorial by LostKobrakai. And even though there are excellent modules available that satisfy specific development requirements, there is still a need (at least for me) for a centralized location of instructional information. The resulting tutorial code samples could then be integrated into the appropriate sections of the cheat sheet and the general documentation.

  • Like 1
Link to comment
Share on other sites

I think clsource and rick are right; even a tutorial for those new to ProcessWire should assume a general understanding of entity relationships, procedural programming, html and css, and it should concentrate on the methods and design patterns that beginners can easily implement to craft a site with typical components such as general pages, blog posts with categories and tags, a simple contact form and maybe a simple user management to protect a given page (and its children) on the frontend ("customer area"). By choosing a css framework, you can skip the design process altogether.

  • Like 1
Link to comment
Share on other sites

One more thing to add. Yesterday I decided to utilize clsource's class:

https://processwire.com/talk/topic/4550-debugging-tips/?p=108300

I added namespace ProcessWire; to it and modified it a tiny bit so that I can also log the class/type name of the logged variable, and the file and line number of the caller. Recommending an easy to use method for debugging (that even works in production, on whatever server this site might be running) seems to be a good idea to include.

  • Like 2
Link to comment
Share on other sites

One more thing to add. Yesterday I decided to utilize clsource's class:

https://processwire.com/talk/topic/4550-debugging-tips/?p=108300

I added namespace ProcessWire; to it and modified it a tiny bit so that I can also log the class/type name of the logged variable, and the file and line number of the caller. Recommending an easy to use method for debugging (that even works in production, on whatever server this site might be running) seems to be a good idea to include.

I would love to see that code :D

Link to comment
Share on other sites

Edit: an updated version of the the following class can be found here: https://processwire....-tips/?p=110290

<?php namespace ProcessWire;
/**
 * Helps with the debugging log
 */
class Flog {
    protected static $name = 'flog';
    protected static $firstSave = true;

    public static function init() {
        if(!file_exists(self::filename())) {
            self::log('f-log debug file created...');
        }
    }

    public static function log($param, $file = '', $line = '') {
        $prepend = '';
        if (gettype($param) != "object") {
            $prepend = gettype($param);
        } else {
            $prepend = get_class($param);
        }
        if (is_array($param)) {
            $param = json_encode($param);
        }
        if (self::$firstSave) {
            self::$firstSave = false;
            wire('log')->save(self::$name, "________________________ Flog log _______________________");
        }
        if ($file) {
            $file = basename($file, '.php');
            $line = $line . ' ';
        }
        wire('log')->save(self::$name, "$file $line"."[$prepend] $param");
    }

    public static function filename() {
        return wire('log')->getFilename(self::$name);
    }

    public static function name() {
        return self::$name;
    }
}
The original class was dubbed Debug, which is used in the ProcessWire namespace, so I had to rename it. The "Flog log" line helps me quickly identify the various "logging sessions". File and line number can be used to identify the states of the same variable and later on to clean up (delete) all the temporary log method calls.
I use a shortcut to quickly insert Flog::log($var, __FILE__, __LINE__); into the code, I just have to overwrite the variable name, and save+refresh the browser (using a shortcut in this case too). A code editor is used to keep the log file(s) open, which refreshes the open files whenever they change. I can delete lines from the log at will, since it is an actual editor. Simple but effective, I got used to this a debug workflow, since it can be used in any environment.
Edited by szabesz
  • Like 1
Link to comment
Share on other sites

@benbyf You might find this class useful if you want to introduce the classic way of php debugging:


Another thing that might be of interest is a short introduction to the main components of ProcessWire. What important building blocks are used in the CMS/framework, what they are for, how they work together, and which ones should be further studied as starting points, how modularity is implemented (CMS vs CMF). Such as: message system, logging system, 3.x compilation, wire calls, etc...

Something similar: cms architecture diagram

And links to Ryan's blogpost or other related doc pages for further study.

I have not found anything similar so far, and it would help me a lot, I'm sure :)

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

my beginners guide is now live on Tuts+: How to install and setup PW CMS http://webdesign.tutsplus.com/tutorials/how-to-install-and-setup-processwire-cms--cms-25509

I also saw that Francesco Schwarz post went live today: 4 Reasons to Choose ProcessWire as Your Next CMS http://code.tutsplus.com/articles/4-reasons-to-choose-processwire-as-your-next-cms--cms-25062

  • Like 13
Link to comment
Share on other sites

  • 2 weeks later...

Yeah just read it. Since I came across the delayed output (and using leading underscore for view files)

I fell in love with it. Set variables (or placeholders as some call it) with init values, output them in _main.php,

give them overrides as needed in a template file. Use wireRenderFile() for view files. You can in fact

stack your site with any layers you want, outputted in _main.php :)  ;)  ^_^

  • Like 2
Link to comment
Share on other sites

Yeah just read it. Since I came across the delayed output (and using leading underscore for view files)

I fell in love with it.

That's just the thing with PW: there's rarely a "right way" to do something. When it comes to things like templating, I still think that for a beginner it's best to start with the simplest possible scenario, which would be direct output. Once you grasp that, it's much easier to understand how delayed output or some of the more advanced output strategies work.

For an example my own favorite output pattern is loosely based on model-view-controller. It's entirely based on template files, and comprised of a shared front controller, template-specific controllers and view scripts, partials, and layouts. The result is a structure that in my opinion can be easily adapted to all kinds of sites, applications, and so on.

Would I recommend this as the first thing a complete beginner should learn? Probably not :)

  • Like 1
Link to comment
Share on other sites

For an example my own favorite output pattern is loosely based on model-view-controller. It's entirely based on template files, and comprised of a shared front controller, template-specific controllers and view scripts, partials, and layouts. The result is a structure that in my opinion can be easily adapted to all kinds of sites, applications, and so on.

Would I recommend this as the first thing a complete beginner should learn? Probably not :)

Interesting, would you be able to share your layout as a site profile, or at least show the folder structure?

Link to comment
Share on other sites

  • 3 months later...

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
 Share

×
×
  • Create New...