Example Website Project in GITHUB?

(Priit Pärna) #1

Hello! And big thanks for PushType… it’s the way to go!

What about one example project where people can check all these tricks you guys are using to tie up nodes with other nodes with fields what so ever… and use them all at one front-page (blogposts, etc all in one place). How proper navigation is done etc. It would be a good guide for all of us who start from the scratch :slight_smile:


(Aaron Russell) #2

Hi @chemic thanks for suggesting this. This has come up before and I agree - definitely something we should do. Not sure on a timeframe, but this will happen!

(Priit Pärna) #3

@aaron cool! If https://www.pushcode.com/ runs on pushtype… strip it up… and push it to github :smiley:

PS! As I already did this thread… can you please make me a short example how would you build a site navigation?

I currently ended up with (written in HAML)

    - pages.published.where(type: 'Page').each do |page|
        = link_to page.title, node_path(page.permalink) 

Where pages = @node.children

Problem with that approach is that I have two different type of node’s for pages… I have HOMEPAGE what contains PAGE nodes… so on HOMEPAGE the navigation fills up well, but not when I navigate to a PAGE.


(Aaron Russell) #4

For a few reasons I can’t put the Push Code site on github. However, I do want to do something like this, probably also with a “Deploy to Heroku” button so people can get a app running and browse the code at the same time.

Re you question about navigation, it sounds like you’ve got a root level Homepage node and everything a descendant of that. I usually prefer a slightly flatter structure, something like:

* HomePage
* Page
  * Page
  * Page
  * Page
* ArticleList
  * Article
  * Article

The point is there’s no right or wrong way of doing this, so there’s going to be different techniques needed if you want a automatic navigation.

One thing you can do is build the navigation in a before filter, eg:

# application_controller.rb

# before_action_node is a class method available to ApplicationController
# You can pass options to it. Eg:
#   before_node_action(only: [:page, :article], &block)
# In this case we don't need to pass any options - it will be triggered on every node.
before_node_action do

  # Assuming your home page node is a HomePage class
  # this example defines a @navigation instance variable
  # an array of all the homepage's children, available in all your views
  @navigation = HomePage.first.children.published.all

  # Alternatively you could try a different technique
  # this example @navigation is a hash tree containing the entire site
  # only recommended if your site is relatively small
  # and you'd need a helper method to iterate through the hash and render the nav
  @navigation = PushType::Node.hash_tree


Hope this helps point you in the right direction :slight_smile:

(Aaron Russell) #5

@chemic thought you might be interested in this: