pushtype / push_type

PushType is a modern, open source content management system for Ruby on Rails.
http://www.pushtype.org
Other
290 stars 32 forks source link

Unable to assign Article to blog when Blog (Parent) is created after Article #26

Closed danobot closed 7 years ago

danobot commented 7 years ago

I created a Blog style app and I created articles first before figuring out that I needed a Blog node in order to display Articles in an index view.

It turns out that I cannot add articles to the newly created blog from within the backend. This is more of a feature request. I'm very new to this CMS so if threre is a way to do it please let me know. How do I get a list of articles associated with a particular tag stored in tag_list? How can I make additional variables available in my views (where is the controller)?

The documentation is very brief and there are no Stack Overflow questions.

kirillian commented 7 years ago

I can answer a couple of these as I have an app where I've encountered similar issues, but I can't answer all of them. I don't think there is a way to add articles to the 'blog' through the UI (yet. Please correct me if I'm wrong. I just reseeded my data to solve my own problem). You will need to go into your rails console.

bundle exec rails c

Example console output:

Loading development environment (Rails 5.0.1)
[1] pry(main)> n = PushType::Node.first
  PushType::Node Load (0.7ms)  SELECT  "push_type_nodes".* FROM "push_type_nodes" ORDER BY "push_type_nodes"."id" ASC LIMIT $1  [["LIMIT", 1]]
=> #<Article:0x00559aee3f5690
 id: "0c2e0594-3542-42e7-b9db-5188162d3080",
 type: "Article",
 title: "Test Article [4]",
 slug: "test-article-4",
 field_store: {"body"=>"Here is some pretty cool stuff.", "meta"=>{"tags"=>["tag"], "summary"=>"stuff", "header_image_id"=>""}},
 parent_id: "8de6a9ff-de3d-47f6-9c2d-9bdce50a2310",
 sort_order: 4,
 status: "published",
 published_at: Sat, 03 Dec 2016 07:40:15 UTC +00:00,
 published_to: nil,
 creator_id: "79571a41-70dd-45da-b792-a5caa4b1d101",
 updater_id: "79571a41-70dd-45da-b792-a5caa4b1d101",
 created_at: Sat, 03 Dec 2016 07:40:15 UTC +00:00,
 updated_at: Sat, 03 Dec 2016 07:40:15 UTC +00:00,
 deleted_at: nil>
[2] pry(main)> blog = PushType::Node.where(slug: 'Blog')
=> #<Blog:0xXXXXXXXXXXXXXX>
[3] pry(main)> n.parent_id = blog.id
[4] pry(main)> n.save!

As you can see, the idea is to find all the nodes you want to add to your blog and update their parent_id. You could do this in a migration too...

The second one is harder. In fact, I believe that filtering based on tags was a feature that is already on the timetable. However, I monkeypatched something in myself to help me deal with my own problems: https://gist.github.com/kirillian/da4a7aefcacb0975b8e38e068f7fb44f. It's certainly not perfect or glorious, but it helped me START filtering on tags.

The third question I think is a bit vague. You might try explaining what variables you are trying to get access to. You probably need to utilize the presenters: https://discuss.pushtype.org/t/how-to-get-markdown-fields-to-render-as-html/79/2 https://discuss.pushtype.org/t/markdown-presenter-method-returning-static-value-of-markdown-field/83 https://discuss.pushtype.org/t/wysiwyg-editor-fields-are-showing-markup-in-the-browser/21/2

As you can see, discuss.pushtype.org is a pretty decent place to get some help. That being said, this product is in beta and there are quirky things because of that that probably will require some knowledge of Rails and some guesswork to tackle (e.g. The app doesn't autoload certain file types for me unlike a regular Rails app and I had to manually add presenters to my project), but all in all, it's a great vision of what could be and it's the first CMS that I've been happy to work with.

aaronrussell commented 7 years ago

Hey @danobot not sure why your post on http://discuss.pushtype.org got flagged as spam. Apologies about that. I've answered all your questions there:

https://discuss.pushtype.org/t/unable-to-assign-article-to-blog-when-blog-parent-is-created-after-article/188

@kirillian thanks for chipping in. You might want to take a look at my answer re querying tags. There are some built in ways to do this (sorry it's not document well yet).

https://discuss.pushtype.org/t/how-do-i-get-a-list-of-articles-associated-with-a-particular-tag-stored-in-tag-list/189?source_topic_id=188

kirillian commented 7 years ago

@aaronrussell Thanks! As you suspected, I didn't realize it was available. I did this a while ago, so I'll have to revisit it and check things out, but I'll likely be removing that patch now that i know!