I'm using D7, and I've created the Content Type 'Poll'. That said, I want to add a specific Poll I've created to a published Blog Entry. Is this possible? I thought about creating a poll block, but this would just publish the same poll on all of my Blog Entries? I also can't seem to add a specific Poll field to my Content Type 'Blog'...
1 Answer
You need to install Entity reference module
Then in your blogs content type, add a new field
- Name: [what ever you like] I named mine aaaa
- Type: entity reference
- Widget: auto complete.
- Then on the settings page for Target Bundle select poll.
Then edit your block, and in entity reference field (aaaa), type your poll name and save changes.
In Views, create a block view of poll.
Under Advanced, RELATIONSHIPS add Entity Reference: Referecing entity NOT referenced.
Checkmark require this relationship.
Then add a CONTEXTUAL FILTER of Content: Nid
For Relationship, select your referecing
Provide default value, Content ID from URL.
Note: your view preview will be blank, but it will show up when you view the blog.
Lastly, in blocks, assign your view block to a region.
Now this will automatically show the poll that you reference in your blog.