I am new to Drupal and I want to make a Metro-style set of shortcuts to webapps in my Drupal 7 installation.
I want to make it dynamic, so anyone user with permissions can edit them in Drupal.
From what I see, I need the following fields:
Icon URL / Icon Image
Title
Body
Color
URL
So, should I create custom type "My Custom Menu" and use Views module to retrieve them and a views-MYVIEW.tpl.php file? Or can this be done in other simpler way.
Thanks a lot.
I'd use a Node and views to achieve this. I don't think you need a tpl for this, I think some css will do just fine.
Just create your Node with those fields
Create your view as an unordered list
I would make the order Color (hidden), url (hidden), Global: custom text, Image, title, body, Global: Custom text
Set your css on the views row to float left
set your css on the views row to 50%, you might need some adjusting here to allow for the padding
Then just adjust your css to get the other elements in place
For the first global custom text
remove the label
Go to the style accordion and set the Customize field HTML to None
Go to the style accordion and set the Customize field and label wrapper HTML to None
Set the text to something like
<div class="[color_field]"><a href="[url_field]">
For the second global custom text
remove the label
Go to the style accordion and set the Customize field HTML to None
Go to the style accordion and set the Customize field and label wrapper HTML to None
Set the text to something like
</a></div>
The Global Custom text fields will create a wrapper around all of the fields within the views row for your color and link. Look at your Replacement Patterns accordion for the names of your fields in the view, I've used color_field and url_field as placeholders above
I think the best way is to use Views and then style using css. In your view format use either GRID or MASONRY API to achieve the metro layout and show FIELDS. Use the Fields to fetch your desired content from the published content.
You can use special content type and view to get nodes in that type as other people suggested. Also you can use views_get_view_result()
https://api.drupal.org/api/views/views.module/function/views_get_view_result/7
To just get array of nodes and loop trough them on your own, without using any template files. This way you can use totally your HTML and just print out values from results array this function returned.
But, you can do it totally different way. If you are showing this to i.e. your home page you can add all those field describing your menu to home content type and you can use field collection module which allows you to repeat group of fields. So you can make a group of all fields describing single menu item and make it repeatable. And inside your home template file you'll simply get an array of those field groups / menu item objects.
https://www.drupal.org/project/field_collection
Related
I've been making a template for a particular content type, but just ran into a problem: I need to embed a view into the content type.
I am aware this can be done via several different methods, but I don't see one that fits exactly my needs:
I need the view added automatically for all pages of that content type.
Using blocks in a region is not an option, as I want to avoid defining a region in the middle of a page that should only be available for a specific content type.
Translatable label.
Possibility to freely apply a template to all fields in the content type (excluding the embedded view).
I tried doing it via page layout (Panels) and simply adding node content fields and the view to my layout regions, but then I get another problem: I can't style my content fields without doing something that seems a bit over the top:
Currently I have about 20 different content fields in the content type that are wrapped in HTML and styled in my template file. I have a translated label for each of these in the template file. From what I can tell I'd have to add a template for each of the panes containing content fields to add my translated labels and HTML needed to style each field.
I'm not really fond of making 20 templates, 20 theme hook suggestions to get the templates to work and 20 regions in the panel layout just to get a view inserted in the content type.
Am I doing something terribly wrong here? Any suggestions?
You may want to try the Viewfield module or similar modules (search for "view field" or "view reference").
If you are doing something more complex like changing/filtering the view based on some value in your content type, then you may have to use Viewfield module in combination with something else that will help fill in the filter values.
I've never done something like this before so I'm not sure exactly what module combination would work but Rules or Computed Field come to mind as possible helpers.
You have to use "views node field" http://drupal.org/project/viewsnodefield, after installing this module you have to select the "Node content" in the display (like blocks,page). then click the add display. if you want to display the content like this page http://www.richtown.ae/?q=content/arabian-ranches then you have to download the views_galleriffic module and install it and choose the style option "Galleriffic Gallery". You can choose the content type by using the filter in the views.
That's it cheers
i implemented this in my website richtown.ae
if you still unclear please send me the email social#richtown.ae i will reply you & ready to help you we can share information
i am using this module in drupal 6.
I resorted to using the EVA module ( http://drupal.org/project/eva ).
In addition to Woodgnome's answer
Let's say you have a content type named 'Product'
You want to attach a view to it.
Here are the steps using the eva module :
On your view edit page :
Section Displays
+Add : Eva field
Section ENTITY CONTENT SETTINGS
Entity type:Node
Bundles:Product
That's it, going to a node product type will now display the view
Currently I have a Drupal installation which has colorbox installed, this allows me to upload a group of images with some text, each entry is its own entity but are all listed on the same page.
I was just wondering if there is a way that I can display a custom link under each views item (entity). Is this possible?
I'm looking for a quick way to simply add a link that links to the first image of the colorbox image slider.
First, set your Format to Show: Fields. To do so, click the link next to Show: (refer to the picture below) and change it to Fields.
If your Format is set to Show: Fields, you can add a new field of type Global: Custom text. Then, in the text box that appears, simply insert your custom link. If you need to pull in the URL dynamically, use a Replacement Pattern (see the list under the text box).
If you need to use another field as a replacement pattern, add it in the same way as you added the Global: Custom text field but make sure to check the Exclude from display checkbox so that it is not shown in your view.
I want to make a long page consisting of multiple nodes (each of the same Content Type). The page should have navigation on top of it that will allow to jump directly to the desired point of the long page, kind of like here: http://www.apple.com/macbookpro/features.html (there navigation is under the picture)
I used the Views module to assemble a long page from content, and for navigation I tried to use another View of the same content, only inserted in the top of the page as a block. I set this view to display grid of fields; it looks good. Only I could not figure out how to make each cell in the grid to become a link to the content on the same page.
I tried modifying views template, but there $rows variable turned out to be a string with already assembled html. Maybe I could possibly modify the content template, and insert some sort of condition that will change the way content looks based on what part of the page current view is located, but I am not sure how to do that either.
In the views, edit the field selected, and there are options there to configure the field as hyperlinks how you may want them. Also you can just let the field link directly to the node, there is an option for that. cheers
First take a look at my node setup here: http://imgur.com/a/DJdRw
The first image is my Subpage slider content type which accepts multiple images and will essentially be my slideshow.
Second image is the default page, but I added a node reference to the Subpage slider node. It allows you to associate a particular slideshow to a page.
The last image I was messing around with Views and Views Slideshow, but I don't know what I'm doing. I managed to get images displayed, but as you can see it displays the images of a long vertically. I set the Views slideshow and it creates a slide between multiple nodes and not the multiple images in ONE node.
Where do I go from here?
Thanks
To display a block with a slideshow of images (from a referenced node) when viewing a page
I have come up with a much easier ("duh" moment) way of doing this. I created the functionality on a fresh Drupal install. Assuming you have the following modules: CCK (w/ Node Reference enabled), Views, Views Slideshow, FileField, ImageField.
Create your content types (in this case: slider and using the core page type)
Add an imagefield to the slider content type (field should be named field_images)
Add a node reference field to the core page content type (field should be named field_slide_ref)
Edit the node reference field settings (can remove "Required" if you like)
Create a new view called slideshow
In the slideshow view:
Change Basic Settings->Style to "Slideshow"
Add the field "Content: images" (choose Format: Image at bottom, unless using ImageCache)
Add an argument of "Node: Nid" with the settings:
Add a "block" display
Enable your new block labeled "slideshow: Block" at example.com/admin/build/block
If configured correctly, when viewing a page with the _slide_ref_ field referencing a slider node, you should see the slideshow displayed in the block.
Old Solution...
To display a referenced slideshow inside the page node being viewed:
Download, install and enable the View Reference module
Create your content type with multiple images (Subpage slider) [Done]
Create a new "page" view in Views UI. Add the field Content: YOUR_IMAGEFIELD (from Subpage slider) important: don't group the images, under Basic Settings->Style choose "Slideshow" and add an Argument of Node: nid choosing Provide default argument->Node ID from URL as argument settings
Create a view reference field on your page content type where you want to see the slideshow and select the view(s) that can be referenced and in the "Arguments" fieldset check: Allow delimiter seperated values and click "Save field settings"
Now when you create a default page there will be a view reference field to select the view you want to use and an argument field where you can input the node id of the node with your images you want to show as a slideshow in your page.
THE QUICK SOLUTION: a really simple tweak which the Views Slideshow docs should put in lurid bold gothic writing:
If you want to slideshow multiple images from an image field of one node ** don't forget to untick the "Group multiple values" checkbox in the settings for your-view>Fields>your-image-field **
This outlines how to make a slideshow of images that are taken from one node. The main point here is that you have to make a block that has an argument of node id taken from the url. I used this to make a slideshow showing as a block in the main content area, but you can of course put the block anywhere.
Modules:
CCK
imagefield
views
views_slideshow OR jCarosel
Create your Content Type with an image field, allowing multiple values.
Create content with multiple images, distinct enough so that you can tell if the images are from one particular node or another node
Create a new view as a node.
Create a Block display
Give your block a name (under Block Settings, left column)
Filter as: published, as your Content Type and with the image field (important - see last step why).
Field: your image field.
Make sure to uncheck the 'Group multiple values' checkbox
Display as an image, or an imagecache preset. Whatever you like
Add an argument:
Node: NID
For 'Action to take if argument is not present', select 'Provide Default Argument'
Node ID from URL
Under 'Basic Settings' select
If using views_slideshow, select the Style to be: Slideshow (Single-frame).
Items to display: unlimited
Save your View
Go to your Blocks page (/admin/build/block) and place your newly created block into the main content area (or wherever you want it to be). If you need to set the visibility on the actual block itself (/admin/build/block) then go ahead but otherwise only nodes of the content type that has multiple images will show the slideshow of images, while other pages on your site will not. This is why it is important to set a specific filter and to use the argument.
Done!
Essentially, this does not work as a page but has to be a block. The slideshow will use the NID to see what images are in that node and create a slideshow of those only.
Should work the same in Drupal 7 but have not tested this.
The solution is to add as argument not the 'node id' but the 'slideref field' and provide default argument 'nid by url' and the slideshow by node will work.
You can use the Views Nivo Slider as well.
I'm trying to theme a single "display" in a view. What I'm trying to achieve is to have some control over how the row is rendered (eg. print the fields in the row, and maybe add some text in between. along with some divs for styling purpose). I've looked for days for the template to edit. I've used even the Theme Developer and the View's Theme Information, but no luck. All
My view's name is Calendar, and there are a bunch of displays. Could anyone tell me what I should do in order to customize the rows in this particular display? Does drupal even provide this flexibility?
The Name and Title of my display in the Calendar view is:
Name: List view
Title: List
Here's the theme information for row style:
Row style output: views-view-fields.tpl.php, views-view-fields--calendar.tpl.php, views-view-fields--page.tpl.php, views-view-fields--calendar--page.tpl.php, views-view-fields--calendar.tpl.php, views-view-fields--page-1.tpl.php, views-view-fields--calendar--page-1.tpl.php
Could someone tell me how to
Edit:
(Some additional information the OP posted in an answer)
I'm using Drupal 6. I'm not sure what page-1 indicates here The following is the list of display I have in this view:
Defaults
Calendar page
Calendar block
Month view
Week view
Block view
Upcoming
List view
Ongoing Block Feed
As you see, none of which has the string "page-1". I edited views-view-list.tpl.php, one of the file listed for "style output". The only variable I have access to is rows, which is an array containing all individual rendered "row". Like I mentioned before, the rows are generated somewhere else, and already contain the rendered fields. How can I customize these rows?
You shouldn't have to add anything to template.php if you are using Drupal 6.
The list of possible theme files that you have there goes in order from least to most specific. For instance, the first one, views-view-fields.tpl.php, will apply to all fields of all views on your site. The last one, views-view-fields--calendar--page-1.tpl.php, will only apply to the "page 1" display of the "calendar" view, so I'm guessing that's the one you want to overwrite.
When you click on Theme Information in the view, the display provided ("page 1" or whatever) applies to the display you are currently on. So if you want to theme fields in a certain display (the "blocky block" display of the "calendar" view, for instance), then you would click the "blocky block" display in the vertical menu on the left, then click Theme Information for that display.
So once you figure out which one you want to use, make a new file in your theme directory with that name, then copy of the contents of the current theme file (click the name of the theme files section on the Theme Information page) into your new theme file, then edit away. Remember, if you overwrite a theme file, you have to click "Rescan template files" in the Theme Information page for the new file to take effect.
Hope that helps!
The displays have custom names on the surface only, but internally they are referenced by id. 'page_1' will be your first display of type 'page' (blocks will become 'block_[id]', feeds will become 'feed_[id]' and so on).
So if you posted your displays in order, 'page_1' would be the 'Calendar' display. You can check this by looking at the links under the display entries in the display listing on the right of the views config page. They will have anchors named '#views-tab-page_1', '#views-tab-block_1' and so on.
As for overriding the templates, be aware that if you add a new *.tpl.php file, you need to reset the theme registry for it to be 'picked up' by Drupal.
Have you added the custom code needed in the template.php file? I know in drupal 5 you need to put code in 3 files:
template.php
views-views-fields--[name].tpl.php
views-views-fields--[name].css
Also you might try:
http://drupal.org/node/128741
answering the second question: the style output is not the template you're looking for. row style is the template that edits how fields are arranged within the row. if you want to edit how a particular field outputs its content, then the specific field template should be edited.