Piranha-CMS How do you get the Post to display on the Page? - piranha-cms

I need to get the posts to display on one of my pages...
How to I do this? Can I create the link via the database? I would prefer this if possible as I'm way better at sql than C#
Cheers

There's are two regions you can add to your page type, Posts & Post Models. The first only loads the general information while the second loads the entire post models including all extensions.
Then in your page you get to select which post type, the number of posts, included related entities & sort order for the posts.
You can read about the included standard regions here:
http://piranhacms.org/docs/pages/regions
Regards
/HÃ¥kan

Related

Querying an implicit re-orderable list

I was searching for a way to re-order my records, like blog posts, for instance.
One of the solutions I have found is to self-reference to refer to the previous (or next) value, like in a linked list (https://softwareengineering.stackexchange.com/a/375246). However, this requires the client-side (a web service or perhaps a mobile app) to implement the linked-list travesal logic to derive the order.
Is there a way to do this at the database level?
The reason for this is that if you are deriving the order at the client-side, then if you want to display only the first 10 records, you would have to retrieve all the records anyway.
EDIT
It seems the blog posts example was a very bad example, sorry. I was thinking of blog posts as they are displayed on an admin dashboard, and the user can re-order the position they are displayed by dragging and dropping. Hope this is more clear.
EDIT 2
I guess, generally, what I'm really asking is, how can one implement and query a tree-like structure in SQL

Why sub resources need to be prepended with resource in URI?

Having a doubt on REST API URI design.
Let's consider each Post has one or more tags. So, a tag could be retrieved by
GET /posts/1/tags/1
Tags are stored uniquely in DB with an ID. So I could access full detail of a tag using
GET /tags/1
If Post information needed, then I could use query parameter
GET /tags/1?post=1
My question is why the first format widely suggested over second/third format.
Suggest me use case/scenario to prefer first format or complications with second/third format.
why the first format widely suggested over second/third format.
This is not the case. The three are used for different things.
You must first ask if a tag can exist without a post. I'd say yes. Because of this, the second form
GET /tags/1
is a good URI to get the representation of a tag.
Next, ask yourself if a post can have multiple tags. I'd again say yes. Because of this the first form is a good way to get a specific tag of a post. More general, the form
GET /posts/1/tags
returns all tags that are used for post 1. This is a collection resource. One of those tags is tag 1 which can be navigated to by
GET /posts/1/tags/1
Note that the first and the second form both identify tag 1. Both forms can be used at the same time.
The third form makes no sense at all. Query parameters after the ? like post=1 are generally used to filter a collection resource. One could say: "Give me all tags that are used on posts 1, 23, and 42. This could be formulated as
GET /tags?post=1,23,42
Here we filter the collection resource of all tags by a condition.
Your third form uses a query parameter post=1 on a single resource. But it makes no sense to filter a single tag.
A fourth form could be useful: Give me all posts that use a tag:
GET /tags/1/posts
This would return the collection resource of all posts that use tag 1.
And even a fith form with the same meaning as fourth would be possible:
GET /posts?tag=1
Summary:
When thinking about REST URIs, think about resources. What are your resource? What are the relations between them? Can one type of resource exist only "inside" another type of resource (a hotel room can only exist inside a hotel) or can it exist on its own (a tag can exist even if not post is tagged with it). What could be a subresource of another resource? What collection resources exist? How can they be filtered?

How do you split one schema.org item across several pages?

I have a single page describing an organisation marked up with schema.org data, there are then multiple related pages with review data on.
At the moment these review pages have the same Organisation tag as the main page but this doesn't feel right to me, it seems like there should be one Organisation record for each company.
Does anyone have an experience or guidance on this matter or the best way of marking up review data on related pages?
-- I have thought about using the organisation url parameter on the review pages which points back to the main page but I am concerned this would eventually impact the listing of these review pages.
Updated with examples
This is an example of the main organisation page http://www.insidebuzz.co.uk/law/hogan-lovells
And this is one of the sub pages http://www.insidebuzz.co.uk/reviews/hogan-lovells/question/overall-satisfaction
[update 5/17/2013]
I've now found that the way we can link items from one to another is with itemid=". This link is to the WebSchemas/ExternalEnumerations page "Country" example. This example shows how this is done. Pay keen attention to the "itemid" usage.
NOT THE ANSWER:
Per HTML - Living Standard -- We can use the HTML5 Microdata "itemref" to accomplish your goal.
[example removed for brevity]
I've done this in MVC by placing the itemscope itemtype="... in the MVC equivalent of a Master Page and in the View's (child pages) used itemprop and itemref etc.
NOT THE ANSWER:
http://schema.org/CollectionPage
isPartOf = Indicates the collection or gallery to which the item belongs.
Hope this helps.

Many to Many Relations in YII

I'm trying to create a blog system using YII. Examples and Tutorials are available. But they use a multi-value table for a Post. Its something like
Post(Id, Title, Content, Author, Tags)
Here there are multiple values (separated by comas) in Tags column. So I created a schema to avoid this and now I have tables like this,
Post(Id, Title, Content, Author)
Tag(Id, Name)
PostHaveTags(Post_Id, Tag_Id)
after normalizing the schema.
I could manage to make a relation in relations() method. But I cannot figure out how to get inputs from a view and validate values of 'tags'. Can anyone help me regarding this please?
Thanx.
You can try to use javascript to allow your forms to grow dynamically and include zero, one or many tags. which you can validate in the model using custom validation rules.
Finally I found the solution. And here is what I did,
First I got the appropriate data from the view and validated them, defining some rules. Then in the afterSave() method I inserted the gathered data into relative relations manually. I don't know whether there is an easy way. But I think, if so, YII will generate the code for us. :)
Thanx guys for helping.

Specify items per page

I'm trying to query Picasa Web Albums to pull album/photo data (obviously!) however initially I only need to pull the first 4 photos. Is there any way to limit a particular field or specify the items per page?
I've already accomplished something similar with Facebook's Graph API however I'm unable to find anything similar for Picasa. The only items I can find related to limiting the response is specifying which fields, but nothing related to the number of rows.
Use max-results argument. See doc here.
https://developers.google.com/picasa-web/docs/2.0/reference#Parameters