Get nid of a view in Drupal 7 - drupal-7

I created a view that makes a block for my homepage. I need to render this block in my PHP. Problem is, I need the nid to render the node and I usually get these by going to Structure -> Blocks -> Click configure and the ID is in the page url at that point. For this view I created, there is no ID, just /admin/structure/block/manage/views/cfps-block/configure.
How can I get the ID so I can render this programmatically?

If i understand your problem correctly.
Open you view
For example:
Blockquote
example.com/admin/structure/views/view/custom_view/edit
get the Machine Name of that view suppose it is block, than you can render it by using following code.
echo views_embed_view('custom_view', 'block');
Read the manual if any confusion:
https://api.drupal.org/api/views/views.module/function/views_embed_view/7

Related

In Drupal 7 views how to give external link (another website) to a title?

Iam new to drupal 7 views.
I have a content type contains title, description fields. I want the content title's to scroll at the top of the page, so that i created a view and it works fine.What is my question is, i want to link a content (eg: 1st content (title) in a scroll) to another website instead of content page, the remaining contents linked to the content page. Is it possible?.If it is possible how it can be done?..
Thanks in advance,
A.John Melchior.
Yes, it's possible.
One way to do it, would be to use the Link module to create a link field in your node.
Use the link field to input the external link value.
In views add the link field, before the title ( order is important ) and exclude it from display
Add the node title field in the views and in the rewrite field output option, use one the link field token as your path.
I'm not looking at the Views UI right now , but you should find at least a couple of ways to redirect content when the node title is clicked. You should have the Rewrite field output and the Output this field as a link.
You could make use of Display Suite coupled with the description above.
Create a link field for your nodes.
Create 2 view modes for your content type via Display Suite. View Mode 1 will show the link field as the first data element, View Mode 2 will show the title as the first element.
Configure your view to show output using Display Suite, configured to show the first record using View Mode 1, all others using View Mode 2.

How can i create a DRUPAL view mixed with nodes and files?

as the title says I'm trying to create a view that displays rendered files and nodes together. Normally when you create a view you have to select what type of content (nodes, taxonomy, files ...) you want do display.
What i want to achieve is a view that displays all nodes and files. The files are NOT mandatory associated with a node. But they are also tagged with terms.
Any idea how to solve that?
Thanks in advance,
Fab
Why don't you create 2 block views and then display it in a page?
For example:
Create a view block that displays the files --> "display_files-block"
Create a view block that displays the nodes--> "display_nodes-block"
and then print them in a static page u create,
For example: "Display files and nodes", with id 1.
inside page--node--1.tpl.php write:
$block = module_invoke('views', 'block_view', 'display_files-block');
print render($block['content']);
$block = module_invoke('views', 'block_view', 'display_nodes-block');
print render($block['content']);
This doesn't answer the question correctly but can be used as a work around for getting data from two entities to appear in one view.
Through the UI, you could create a view called FilesAndNodes, and only add Global:Custom Text Area under the fields section.
Then create another view called Files, and add this view under the Header section of FilesAndNodes view.
And then do the same for nodes.
The Block created by the FilesAndNodes view can then be added to the page, and the content appears as one view.

Drupal 7: Adding content/nodes from custom content type pages to another page

I'm working on a Drupal site an need to implement the following:
I have created an about us page template (page--about.tpl.php) and a custom content type for the about us page and linked the 2 using suggestions. I also have a custom content type for staff profiles that I need to add on the about us page in a tabbed format.
I can't seem to find a way to get the staff content to display in the about us page. I would ideally like it to render it the same manner as blog posts would display in a blog page.
So my question is, what code do I use to render all the nodes of the staff profiles content type in the about template page?
p.s I'm a bit of a Drupal noob, done a lot of reading but come up empty on this one.
If you already created content type About us (that is what i understood from mockup and explanation) then maybe you could use Views with EVA. That will enable you to have view as field in content type.
You can set it up with manage display or print it in template as all other fields. For example:
<?php print render($content['your_view_entity_view_1']); ?>
Other way would be to embed view in template. For example:
<?php print views_embed_view('your_view', 'block'); ?>
You can use the excellent Views module to create a block to list all your staffs.
Then you need to place the block that you had created with the help of view module in about-us page.
The Views module will give you suggestions to about which template to use.
EDIT: After the op provided the following image.
After you create a view to show all the Team member nodes you could simply print the view in your about us specific page template using following code.
$view = views_get_view('view name');
print $view->render('display_id');
Another option to do the same thing is, make blocks for all the content, viz. The Firm, The Team, Awards, Technonogly, Services and use quicktabs to display the content.
Yet another option to show a view as a field for a node is use EVA
Going the quicktabs way you can provide a lot of flexibility of showing teaser in about us page and leading to details about the same. For example each award can be a node in itself.

Drupal 7 - How to create a contextual filter based on an aliased url

CASE:
I've created a content type 'Attorney', and have set a url alias pattern for all attorneys to be 'attorneys/[node:title]'. I'd like to create a view that uses the aliased path to display the information about the attorney. This view should have a 'page' display.
EXAMPLE:
When a user visits 'http://mydomain.com/attorneys/aaron-silber' the view returns data for the Attorney with the name Aaron Silber.
BACKGROUND:
I've searched high and low for a solution to this but can't seem to find one that works for me. Typically I'm asked to create a page view with a url of 'attorneys/%' and add a contextual filter with 'Content: Nid', choosing to provide a default value (type: Raw value from URL, path component 2).
The resources on the web for this case are aweful at best. Lets try to fix it here once and for all.
Thanks!
Use a Views block instead with the visibility set to "Only the listed pages" and supply "attorneys/*" in the textarea. Set the block to display in the main content region. Use the Content: Nid filter with a default value of path component 2, as you were previously attempting.
You can't have an attorney node page and a Views page occupying the same URL.

DotNetNuke Switching Between Multple Edit Modules

I have a custom module in DNN 7 that has a data structure where items belong to categories (called "sections", not DNN taxonomy, just a simple list of section names). The module edit screens work so that on the view control you may click on an edit link on each category, which loads the category edit screen (passing the category id). This works great, and when you save I use Globals.NavigateURL() to return to the view screen. This all works as intended.
On each category edit screen I also have a list of the items within that category, each with an edit link. Clicking the edit link opens the item edit screen, passing the correct item id, and allowing me to edit that item. This all works great, until you save. The save works properly, but when I want to send the user back to the edit screen for the category it doesn't work. When I use:
Response.Redirect(EditUrl("SectionId", sectionid.ToString(), "EditSections"), true);
...nothing happens. It simply doesn't redirect anywhere. This is exactly the same URL I'm using to get to the category edit page in the first place:
EditUrl("SectionId", Eval("SectionId").ToString(), "EditSections")
And then I use a similar URL to get to the item edit page:
EditUrl("ItemId", Eval("ItemId").ToString(), "EditItems")
I don't understand why using the same URL to navigate to the same page I already navigated to would simply not do anything. For now I am sending them all the way back to the view, but it's painful if you need to add several items to the same category to have to navigate back into the category and add another item, only to be sent back to the view.
Anyone see anything like this before?
Have you tried to use the overload of NavigateUrl instead of EditUrl?
Globals.NavigateURL(TabId, "EditSections", "mid", ModuleId.ToString(), "SectionId", Eval("SectionId").ToString())
I haven't seen that myself but I would have to assume that somehow the context is being lost with EditURL and you're not getting sent to the proper location due to that.
I would suggest you try one of two things (or both).
Debug the URL that EditURL is returning and see if you can find the
difference.
Use NavigateURL for all your links and pass in MID=## for your
moduleid as a querystring parameter, to ensure that the proper
values are being passed.
UPDATE: If you're trying to have multiple edit views, and move between them, you might look at using a "loader" instead of having separate module definitions for the edit controls. Basically have a single Edit.ascx file defined, and it loads other ASCX files within it, injecting into a Panel. The View control on this module http://dnnsimplearticle.codeplex.com/ does that, but I haven't tried it with an edit control before.

Resources