help me to proceed with drupal views? - drupal

I am newbie to drupal , I just created a view called "master" and i wanna manipulate the output pro grammatically for creating widget (javascript widget can embed in other website).
$view = views_get_view('master');
$view->set_display('page');
$view->execute();
$viewArray = $view->result;
$title = $view->display['default']->display_options['title'];
echo "<h2>$title</h2>";
echo("<pre>"); print_r ($viewArray); echo("</pre>");
It prints the result(in object form), But the output contains only 10 result which was mentioned while at the time of views creation.Please guide me,
1.how to get the next 10 result pro grammatically (pagination) ?
2.how to theme a views pro grammatically (since its js widget) ?
3.any live demo tutorial links to play with advanced views?
4.how to do sorting (whether i need to pass through url)?
5.how deal this with handler object?
my view preview looks like this below image
Thanxs,
Nithish.

Well, for #1 all you need to do is go into the edit control panel for that view and change the number of records to be shown on each page. Setting it to 0 lets it display all records at once.
For the others ... I wonder if views is the right solution for you. I suspect you might be better off with a custom module that returns a lot of drupal_json() calls. At very least, it's cumbersome and wasteful to be doing all this through views, since views spends so many cycles on rendering.
If you want to avoid coding a custom module, I'd suggest installing the View Bonus Pack (http://drupal.org/project/views_bonus) and using the 'Feed' display types. This will make it marginally easier to manipulate the results with js.

Related

Drupal Embedded views not working correctly

I recently took over a site from someone else at a new company. Having never used Drupal before, updating things has been a bit cumbersome. There were some outstanding security updates that I applied(but I haven't updated the core yet). Anyway, after doing this, the calls to views_embeded_view have not been working. For example:
print views_embed_view('news_block');
Will break the links(by using the title, rather than alias for the link), or it will link correctly, but not follow the paging rules I have set(show 1 page, 6 items per page) instead it shows 10 items and has links for other pages.
I am not sure if the update has anything to do with it, but it seems likely. Would updating the core resolve this issue potentially?
The first argument of views_embed_view is view name, the second one is display id. If display_id is not provided, 'default' is used. Make sure that you are displaying the correct display. (i.e. default can be configured differently than some other display which you actually wish to see)

how to find property and element of a $form in drupal

I just started to work with Drupal modules. I have seen in some codes that some elements and properties (if I called them correctly, # for property) are assign to the $form. I have been googling but I couldn't find any useful document that shows this variable (again if I called it correctly) what kind of properties and elements has and in which tables it store?
and how can I debug them ?
i.e. $account_form=&$form;
$account_form['name']['#suffix']
I have check profile.module but it didn't help me!
TNX
If you have a php debuger in your editor you can use it to find out what variables you have. On the other hand you can use print_r($form); and that will show you the array(hint in browser user CTRL+U to see the source, you'll find that in the source the form array looks nicer), or you can use var_dump().
If you want to create the form, and you want to know what options do you have, there is the Drupal Form Api( https://api.drupal.org/api/drupal/developer%21topics%21forms_api_reference.html/7 ).

WordPress - add Database driven tables

I'm just trying to move one of my old php sites to wordpress. As part of the site I have 'top tables' e.g. top 10 cars, listing their features etc. At the moment that all comes from a database and the HTML is generated from the data.
So if a car soon gets a hybrid engine I just check that in the database and my web site table updates to reflect that.
This all works fine. I just don't know where to start when trying to implement something like this in wordpress. I want to keep the WP header, footer, nav... and put my table in to the content area.
Someone recommended simply copying the current generated HTML in to a new post and editing the HTML when anything changes, this sounds like a quick solution but there must be a better way of doing this.
Ideally I would want to keep my current data input pages (and separate database) for all of this 'table data' and present the out put as a post.
If anyone can point me in the right direction (key words I should search for, a guide) that would be great.
Depending on your usecase, you'll usually want to use a static page template:
http://codex.wordpress.org/Page_Templates
Or shortcodes:
http://codex.wordpress.org/Shortcode_API

Why does a basic Drupal view return no results

I am starting out with views and I wrote an extremely simple view which really just filters if the node is published and if it is of type banner. In preview and when I try to print the view I get no results. When I search through my content and filter by type banner and published, I get 3 results (in /content/node/overview). I must be doing something basic and stupid, any suggestions for how I can figure out what I have done wrong?
I am starting out with views and I wrote an extremely simple view which really just filters if the node is published and if it is of type banner. In preview and when I try to print the view I get no results. When I search through my content and filter by type banner and published, I get 3 results (in /content/node/overview). I must be doing something basic and stupid, any suggestions for how I can figure out what I have done wrong?
View:
http://www.randomcrapilike.com/test/view_capture.jpg
Have you tried creating a block view and then seeing if it outputs properly in the block region on the front end?
A few troubleshooting steps based on your screenshot...
Try including the node ID in the fields section to make sure the issue isn't with your CCK fields.
Try a different display type than 'slideshow' to make sure the issue isn't with that (non-standard) display type.
Try taking the preview query and running it directly against your database. Do you get any results or error messages?

Drupal, Views: using AJAX to load the complete node?

I've a View page with all the content of my website (the node headers). When I click on one of these header I would like to load the complete node without refreshing the page and display it on the left.
Can I do this with Views (I mean.. does it have a functionality to load a complete node and add it to the current page ?
thanks
I think it is possible using Views. Views is much more than just SQL generator.
Views can work with Fields, or with full node. Set it to full node.
Views can work with Ajax - set it to "yes" (I think it is Yes by default).
It is hard from your description to understand the whole picture, so I can't lead you any further. All I can say is that I use Exposed Filter with Ajax and load full node properly, chaning the content of the page.
Hope I helped,
You are welcome to ask me directly for further support.
Regards,
Shushu
No. Views is basically an SQL query generator. You can do what you describe with javascript, but I don't know what modules might be helpful.
Check out Modal Frame - http://drupal.org/project/modalframe
Basically, your view displays just the title, and you have "link title to node" enabled. Rather than jumping to node page, u want to display node content in modal frame pop up.

Resources