Drupal 7 - Taxonomy terms based on pages? - drupal

No idea if this is the best way to do this but here is what i'm thinking.
I have a content type called 'Widgets' and each widget is a little piece of content. I wish to then have a generic 'View' which goes off and grabs all the widgets for the current page that the user is on.
Here is how I see it working in my head.. just not sure how to do it.
-When creating a content 'widget' the admin can somehow select a page they want it to appear on from a list taxonomy terms based on the site structure (as new pages are added they are also added to this tree automatically somehow)
-When a user then browses a page the generic view then works out what page the user is on and fetches all the widgets that have been tagged with this current page
Is this possible? and if so can someone please give me some pointers.

I figured this out, in the fields for the main pages you can add a term reference field that allows you to enter a new tag into the vocabulary.
The 'widget' content type can then select this new tag using a term select field. My view then automatically displays it because it is related.

Related

Add taxonomy terms list to homepage Drupal 8

Please help me to add taxonomy terms from custom taxonomy into home page. I have no idea how to do this as I'm coming from WordPress. In WordPress it is easy as calling get_terms(). I have following file as my home page: mytheme/templates/page--front.html.twig
I have more than one taxonomy type and all of them are going to queried in the home page.
How to query the taxonomy terms?
UPDATE:
I have created a new region called home_content in my theme.info.yml and I have created a view(block) for getting the taxonomy terms, added it to region in back-end and display it as {{page.home_content}}. It works but I have few questions.
I have fields for logo and text in the taxonomy. I want to list them too.
I need to customize the html. How can I do that?
Thanks for the support.
You don't really need to code anything
Create view with taxonomy terms required. Structure > Views > Create New View and add block view for taxonomy terms. User filter section to select specific terms or dictionaries. Save the view.
Go to Structure > Block Layout and insert block with your view into desired region. In visibility section, pages tab: type <front> in pages and select Show for the listed pages in order to display it on home page only.
Above steps will display your required terms on home page.
To copy and modify template(s) in your theme, follow the instructions on drupal.org: https://www.drupal.org/node/2358785

Drupal- create new block content everytime new content created

I might be asking for a lot , but any help would be awesome! All I want to do is every time a user (not admin) in Drupal creates content like a blog, predefined blocks in certain regions will allow user to add NEW content (ad's/banners). Is this possible?
I've seen the Node-Level Block, but I am not too sure on how to use it? Would this work? How?
Here's an example on what I am asking above. Say a user has permission to create a blog. They will add content to the blog, along with an option to add new content to predefined blocks, like the right side bar block named RightSideBarBlock. This content per block, will be only seen for that new node created from blog content type. If they do not add content to predefined blocks, the block will show nothing for that node.
Does this make sense?
The display part of your request is fairly easy. You don't have to create a new block for each blog entry, you can use the views module to display the related ad for each entry.
Before starting, make sure you have the views module and the entity reference module installed.
First you need a new content type, call it Blog Ad. It will need a field called Owner that will be an entity reference field pointing to the parent blog entry.
Next, create a new view and make sure you choose to create a block variant and set the number of entries to display to 1. Set the filter criteria to Content Type = Blog Ad. Add a context filter to the view. Select Content: Owner from the list of options (this will let you filter the Blog Ad entries by the owning node id). Since block views can't take arguments directly you have to choose the option to provide a default value. From the option list select Content ID from URL. Save your view and go to the Blocks page.
You will now have a block in in your Blocks page called View: < Name of View >. Add that block to the appropriate region, and under settings, filter it to only appear when the content type is Blog.
Now you can create a Blog entry, save it, create a Blog Ad entry selecting the just created Blog entry in the Owner field, then view the Blog entry. You will see your Blog Ad in the block. Create a new Blog entry and when you view it you won't see anything in the Blog Ad block.
Allowing creation of the related Blog Ad from the Blog creation page can be accomplished using a module like Node Reference Create or Inline Entity Form. I have not used any of these modules personally so I can't vouch for their quality or ease of use, but they will do what you want.

How to assign view block to dynamic taxonomy term page for CCK entries

http://localhost/rkk/work-type/non-profit
I created a vocabulary and terms under for work-type. and I created some posts...
Then I created a View Block to list my entries, and assigned to a page... everything fine so far.
I display the work-type at entry details page. and I have a link "click to see other non-profit(assigned work type) works". When I click this link, it lists entries assigned to that particular work-type. thats fine, but it displays title/body/readmorelink :/ I need custom view for this page, like I did View Block for listing all posts...
Can I assign custom created View Block to this taxonomy entry list page? the url changes according to work-type, so how do I assign view to changing-url :/
Appreciate helps!! thanks a lot!
UPDATE FOR MORE INFO:
I have a vocabulary (work type), and terms under (corporate, non-profit, etc...)
I have a CCK for "work", and as a field I have select terms of work-type vocabulary.
I have a Custom Views Block to display works in a page (thumb, title, desc, link, etc.).
When I click a work, it goes to particular Work entry details page, I place a link in there "click to see other -term (corporate)- works", etc.
When I click this link, it displays the Work Entries under that particular term. it works fine. but it displays as default look (shown as below), but I need this page same as main works page list (thumb, title, desc, link, etc.) I already have a View for this, but how can assign this View to this dynamic url taxonomy page? I found the module http://drupal.org/project/tvi , but cant make it work.
It should be simpler to overwrite term pages with a view, there's already a pre-configured view for this : taxonomy_term (wich is disabled by default)

Drupal Views of nodes to show node comments

I've encountered a Drupal problem: I'm using the Views module for rendering nodes of a kind, based on the user id of it's author (it is a Content Profile actually). I want the view to show the comments for the node, just like in node/%. I could not find any option in views or any relevant module. Am I in the wrong direction and should reorganize stuff for this...?
Any ideas, how can it be done?
Regards,
Laci
Using views is really not the best plan of action. You should instead create a node template in your theme and customize it. If needed you can put some logic in a preprocess function. It requires more coding but will get you where you want.
If you use view node display type
Check in it's settings show comments
if you use view fields display type
Use relationship to comments and select fields you need and theme them
I know this is old request, but I was just struggling with the same issue and came across this post. I thought it'd be helpful to share my solution.
I'm using Drupal 7, with Views 3 and Display Suite.
In your view, choose the display in question.
Under Format, click the first link to the right of 'Show'.
Choose 'Content' (or 'Display Suite' in my case).
Click 'Apply'.
On the next screen, you'll have the option to 'Display comments'. Check this box and save your view.
You should now see the comments displayed under each item in the view.
You could create a second view (with URL e.g. /comments/% where the placeholder will be the node ID, and not the comment ID) that lists comments for a given node, with a contextual filter to only show them based on the NID in the URL.
Then, add that view to the footer (as a 'view area') of the single-node view you've already got.
There's some tweaking required for layout (inline fields etc.) but the basic structure should work.

How to create a simple company blog with a Tag-Cloud in Drupal-6?

I have to create a simple company blog within drupal-6. That means there should be only one single blog each user can post into.
What i have done so far is to create a custom content Type (blog) and a view that displays teasers of the recent blog entries with links to the full blog post.
Now i have to create a Tag-Cloud for this blog.
I created a taxonomy vocabulary for this "blog" content type and set the settings to Tags (Terms are created by users when submitting posts by typing a comma separated list.)
I also installed the Tagadelic Module and created a tag cloud with it, that works great and it displays all the Tags i entered when creating new blog entires.
But now to my problems:
First: If i click on an entry in this tag-cloud the default Taxonomy_term view is used to display the resulting blog entries. Thats bad because i would like to have it displayed the same way as in the view i already defined to show the blogs. Is there a way to use my view to display the results of the tag-cloud?
Second: On my view, below each blog-teaser should be a link to related blog entries (the ones that share the same terms). I do not have a clue how to do that.
is this even possible with the setting i have now or should i maybe take a whole other approach to create that company blog with tag clouds and related blog entries?
You should be able to solve both problems pretty easily, while keeping your current approach:
Take a look at your views list ('admin/build/views/list'). You should see a view called 'taxonomy_term (default)', which is usually disabled by default. This is an optional override of the built in taxonomy term page. You can enable this and configure it to look like the blog view you created.
Alternatively, you could leave that one disabled, but add another display of type 'page' to your already existing blog view, and configure that as an override to the built in taxonomy term. For this you'll need to set the path of that display to 'taxonomy/term/%' and adjust the display to use the term id argument as a filter (look at the above override for how this works).
You could also do it the other way round - use the default taxonomy_term override view, configure its output according to your blog view needs, and add another display for your recent blog entries to that. After this, delete your own blog view and use the new display of the taxonomy term override instead.

Resources