Jump to content
pycode

Learning platform built on ProcessWire

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

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Thank you @flydev for your answer, by try and error came to the solution you posted :) Sorry about that long and unformatted post, seems like I can't edit my posts after few minutes posted, so can't do anything about it already :(

  • Like 1

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Brian Peat
      Hello! I've got a single client on Processwire and it's completely foreign to me. I've been able to find most things, but they've asked for a custom designed page with a full width header image/section, and then a body block and a right side bar below the header. They're using a landing page template, so I duplicated that, figured out how to add it in the admin, and assigned it to the page. Nothing. It doesn't change a thing.
      I feel like I'm missing something obvious. I've made sure all the fields are the same, I tried to set up the parent/child stuff though this page doesn't have a parent that I can tell (though it's under Landing Pages). If I can get the template to actually kick in, I think I can use a bit of code to check for the hero section and load it at the top. I also made a copy of the widget template and set that to load instead of the original. But again, since my main page template isn't kicking in, neither is the new widget template.
      I'd just love some tips on what to check or change to get a landing page to actually render what's in the assigned page template.
      Hopefully I've used the correct terminology here to make sense.
      Thanks!
    • By rookie
      hi there,
      Is there a module or other solution to select a template with a preview image? Sometimes it is not that easy to describe a template.
      e.g. Template with 3 columns (image, title, content, button) or template for a slider with max. 4 pictures.
      Even if it is nice to have a description field for a template, a picture says more than thousand words could describe.
      And no, I don't think I could develop something like that. I don't even know where to start.🙄
    • By muzzer
      I have just upgraded a site from 2.7 to latest v3.
      I have run into a weird issue where a page template setting for slashUrls changes from No to Yes immediately after an ajax call, causing the second ajax call on the page to use the wrong setting.
      There is no reference to the $template->slashUrls() in any of my code.
      This happens every time I load the page, it's 100% consistent.
      I have this running on a second machine under v2.7 and no such weirdness.
      I'm lost as to why this is happening, what would cause a PW setting change for slashUrls? Anyone have any ideas?
       
       
       
    • By Pip
      Hi everyone, 
      Is there a way for us to replicate the "http://mydomain.com/processwire/page/edit/?id=xxx" and change the template to match my site template? 
      I'm terribly happy with the admin / backend page edit. It covers literaly everything I want to empower my non super admin user in updating pages such as validation, repeater management, file upload. 
      I wish not to allow the users to see the backend for both security and aesthetic reasons. 
      Thanks and hope to hear from you soon. 
       
    • By calago
      after the migration to version 3.0.145 our export templates all of a sudden dont work properly, 
      we have a functionality where we use a boiler template with a set of fields. for some reason since the upgrade when we select the export template to export it. it wont show any of the fields added after the migration, 

      as you can see the offer certificate remarks field has been added to the export, 
      but when we select it it wont come trough

×
×
  • Create New...