Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By vmlsd on
I want to have two view types in one view. I want to display the nodes from a taxonomy term. I want to display them in list view but I want the top one to be in full node like below.
------------------- (title)
*************** (body)
***************
***************
***************
-------------------
-------------------
-------------------
-------------------
Previous 1-2-3 Next
how can i do this? thank you.
Comments
Well...
The Views Bonus might do it. Otherwise look into Views Fusion.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
thank you nancyw. i am sorry
thank you nancyw. i am sorry maybe what i described was not clear. actually i want to have something like this.
I want a view that display pages of a taxonomy term in list view sorted by descending created time. so it will display
------------------ (July 22)
------------------ (July 21)
------------------ (July 20)
------------------ (July 19)
previous 1-2-3 Next
However, I want the latest created page(the top one) to be display in full node so it will be like
------------------ (July 22)
.....................................
.....................................
.....................................
.....................................
------------------ (July 21)
------------------ (July 20)
------------------ (July 19)
previous 1-2-3 Next
how can tweak this? i cant solve this with either view bonus or view fusion.
thank you.
Probably need to do it with your theme
But I don't know theme tweaks.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
...
Nancy gave you some very good guidance: you can use theming to change every detail in the output. The handbooks were updated recently to have some really good documentation for Views, so you may want to browse there.
One drawback in theming is that sometimes it means that you need to duplicate existing code, and this isn't always elegant. There's a solution to your problem that doesn't involve theming:
hook_views_pre_view
. (in your case, X is 1.)hook_views_pre_view
returns semething --some string-- it gets prepended to the output. The code I gave returns nothing, so change it to return thenode_view()
of the first node in that array.hi mooffie, I have looked at
hi mooffie, I have looked at your post. But I dont know how to use the function. Could you show me more on this? thank you.
...
You need to put this function in a module. I put it in a module named 'vhead' and uploaded it here. Downloaded both the .module and .info files and then enable the module.
The code is:
It removes the first node in the listing and outputs it in 'teaser' mode. Update
$the_view_name
to hold the real name of your view....
Just for the record:
To achieve the same through theming, you'd do:
(the '_list_' in the function name says it's a list view. Might be '_table_' as well.)
EDIT:
You know, I think it'd be easier for novices to to use this theming approach. Moreover, I don't see a real advantage to the previous approach (that of hook_views_pre_view). Just stick this code in your 'template.php'.
(hmmm.... so, should I delete my previous message? no, I'll leave it be.)
thank you mooffie. both
thank you mooffie. both methods work very well.
hi mooffie, I have another
hi mooffie, I have another question. how to output the first node in 'full node' mode instead of 'teaser' mode.
...
change:
to:
(See here.)
thank you. it works
thank you. it works perfectly.
as I dont want to have the 'read more' link since it is in full node mode, i passed two more parameter values.
$output .= node_view(node_load($the_first_node->nid), 0, 0, 0);
Congratulations
You've just encountered two of the bugs I reported against 5.1 that I think are still there in 5.2.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
i dont quite understand. may
i dont quite understand. may i know what the bugs are?
Subscribing
Curious what bugs are ment..
greetings,
Martijn
They are
Teaser miscalculation and a parameter problem with node_view.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru