Jump to content

Learning platform built on ProcessWire


pycode
 Share

Recommended Posts

Hello PW, 

discovered few days ago this awesome cms and now want to start a project on it, but need some help. I'm coming from the drupal side, which I kinda like, but it is not usable for smaller projects like I need now. I like it's way to build to content from the ground up, but it feels heavy, don't know why. PW feels really light and want to give it a try.

Long story short, development it is a hobby for me, so everything I do is self-learned throw try & error, no programming skills yet. I want to learn JS now, and for that, want to translate a website to my native Romanian language so I can learn myself and others in the future. The site I'm talking about is www.learn.javascript.ru

I want to build a similar structured site (please see the attached image):

pw.png.e4fe2018f6b40722b3a745438ce8fb24.png

Home / Projects / About will be basic page template based, no problem with them.

mysite.com/javascript/

Starting Learn JavaScript will be a basic page template as well, I can make it statit, as it will contain some info and links to the Sections of the JS theory pages.

mysite.com/javascript/section-name/

By accessing a section page, I want to see again some description text and links of the attached unit pages to this section, so when I open any section it shows me all the attached unit pages to it. On the sidebar, I need to render links to all the sections, just that.

Next is unit pages like mysite.com/javascript/section-name/unit-name/

Here goes the units text, main content in other words, like a blog post. The key point is to have a dropdown and select the section page for it. For sidebar, I want to render the list with links for every headline from the unit page. Will do it by using Jumplinks Hanna Code, I believe it will do the job perfectly.

Who can give me a hand with the templates?

first /javascript/ page I can do as a basic page.

next /javascript/section-name/ don't know. what fields should it contain for linking units?

and last /javascript/section-name/unit-name/ again, what field needs to be used for linking? Page refference I believe?

How I write it to templates?

Would be gratefull for your help guys,

Thank you

 

Link to comment
Share on other sites

UPDATE #1

Trying to do it based on Blog Profile. Also modified the structure, so it goes LEARN JAVASCRIPT -> SECTION -> MODULE -> POST

Linked posts to modules and modules to sections with Page Refference, works well.

For first page (learn js) used this template:

<pre>

<?php namespace ProcessWire; ?>

<nav pw-append='content-body'>
    <?=ukDescriptionListPages(page()->children)?> 
</nav>

<aside id='sidebar'>
    <?php 
    $sections = pages()->get('/javascript/'); 
    echo ukNav($sections->children, [ 'header' => $sections->title ]); 
    ?>        
</aside>

</pre>

Works so far so good.

for Section pages used this template:

<pre>

<?php namespace ProcessWire; ?>

<div id='content'>
    <?php
    echo ukHeading1(page()->title, 'divider'); 
    $posts = page()->children('limit=10');
    echo ukPlatformPosts($posts); 
    ?>
</div>

<aside id='sidebar'>
    <?php 
    $sections = pages()->get('/javascript/'); 
    echo ukNav($sections->children, [ 'header' => $sections->title ]); 
    ?>        
</aside>

</pre>

DOES NOT WORK as it gives me an error. <pre>Error: Uncaught Error: Call to a member function count() on null in /Applications/MAMP/htdocs/processwire/site/templates/_uikit.php:777
Stack trace:
#0 /Applications/MAMP/htdocs/processwire/site/templates/_uikit.php(842): ProcessWire\ukPlatformPost(Object(ProcessWire\Page), Array)
#1 /Applications/MAMP/htdocs/processwire/site/templates/section.php(7): ProcessWire\ukPlatformPosts(Object(ProcessWire\PageArray))
#2 /Applications/MAMP/htdocs/processwire/wire/core/TemplateFile.php(287): require('/Applications/M...')
#3 /Applications/MAMP/htdocs/processwire/wire/core/Wire.php(380): ProcessWire\TemplateFile->___render()
#4 /Applications/MAMP/htdocs/processwire/wire/core/WireHooks.php(723): ProcessWire\Wire->_callMethod('___render', Array)
#5 /Applications/MAMP/htdocs/processwire/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\TemplateFile), 'render', Array)
#6 /Applications/MAMP/htdocs/processwire/wire/modules/PageRender.module(514): ProcessWire\Wire->__call('render', Array)
#7 /Applications/MAM (line 777 of /Applications/MAMP/htdocs/processwire/site/templates/_uikit.php) 

This error message was shown because: you are logged in as a Superuser. Error has been logged.</pre>

For Modules used this template, works as intended. Also need to add in the sidebar the list with all the modules of the current section. <pre>

<?php namespace ProcessWire; ?>

<div id='content'>
    <?php
    echo ukHeading1(page()->title, 'divider'); 
    $posts = page()->children('limit=10');
    echo ukPlatformPosts($posts); 
    ?>
</div>
</pre>

And for post used this template. <pre>

<?php namespace ProcessWire; ?>

<div id='content'>
    <?php 
    
    // blog post content
    echo ukPlatformPost(page());
    
    // comments
    $comments = page()->comments;

    // comment list 
    if(count($comments)) {
        echo ukHeading3("Comments", "icon=comments");
        echo ukComments($comments);
    }

    // comment form
    echo ukHeading3("Post a comment", "icon=comment"); 
    echo ukCommentForm($comments);
    
    // link to the next blog post, if there is one
    $nextPost = page()->next();
    if($nextPost->id): ?>    
        <p class='next-blog-post'>
            Next <?=ukIcon('chevron-right')?>
            <a href='<?=$nextPost->url?>'><?=$nextPost->title?></a>
        </p>
    <?php endif; ?> 
</div></pre>

Works as intended, except the linking for next article. I would like to add previous and next links for articles within the module.

Attaching uikit.php, as I believe the problem with that error goes from there.

My php skills are pretty weak, please help to get some light on this project.

Thank you

 

_uikit.php

Link to comment
Share on other sites

  • 2 weeks later...

Hi @pycode, welcome to the forum.

First advice, if you need more answers, try to format your post with the forum tools so it will be more readable by us !

Wrap your code into the code tag, use quote for errors, etc. :)

 

About the error you are encountering, looking at the line 777 of the _uikit.php

$n = $page->comments->count();

It seem that the function want a Page with a comments field registered on the template.

To fix it, just add the comments field to the according template and everything should work.

 

I also suggest you to read this thread :

 

  • Like 2
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
 Share

×
×
  • Create New...