Jump to content

worked! added own lines inside render ! ;)


bwakad
 Share

Recommended Posts

So today I learned about render, retrieving fields / pages and selectors in general. I have to admit, many times I do not know, often I look at Skyscrapers to see some interesting stuff, read the API and see the the forum where many guru's are active. As such I learned some and added my own lines in the render function.


// get field province, from current page, store in location 
$location = $page->get('province'); 

// use  markup, get url and title of location, store in  where
$where.= "\n\t<li><a href='{$location->url}'>{$location->title}</a></li>"; 

// and then finally output 'where' plus it's markup, inside table

$out = "\n<table class='blahblah'>" .
        "\n\t<tbody>" .
        "\n\t<tr><th>Province</th><td>" . ($where ? "\n<ul>$where</ul>" : $na) . "</td></tr>" . 
        "\n\t</tbody>" .
          "\n</table>";

return $out;
Link to comment
Share on other sites

Your head must be a puzzle right now. I have the feeling that you just skipped the basics, and are looking at random things, some even too complicated for starting. I don't want to tell you how you should learn, everyone has it's own way, but I feel that you're taking the longer and less exciting path. Just sayin' :)

  • Like 2
Link to comment
Share on other sites

Are you adding markup inside the render function in the class directly? That's how I'm reading it from your post above.

All of that should be done in the /site/templates/ file for the relevant page template.

This tutorial will help you understand rather than picking apart something more complex: https://processwire.com/talk/topic/693-small-project-walkthrough-planets/

  • Like 1
Link to comment
Share on other sites

I know I know...

I just wanted to see how it works. But you are right. I think markup should be in the template file rather then through render. So it's easier to read.

So I just deleted all files, emptied DB, and started on a fresh dev install (no site profile other then basic one).

Made some pages and some loops to get a list in my template file.

And since this list becomes veryyyyyy long I really need a css to attach, like bootstrap (easy) or foundation (litle hard).

I just don't want all the files like site-profile from http://processwire/modules gives because you all will tell me to start with a fresh install again. lol

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...