<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Views</title>
  <link rel="alternate" type="text/html" href="http://pingv.com/tag/views"/>
  <link rel="self" type="application/atom+xml" href="http://pingv.com/taxonomy/term/218/atom/feed"/>
  <id>http://pingv.com/taxonomy/term/218/atom/feed</id>
  <updated>2008-02-22T11:07:36-06:00</updated>
  <entry>
    <title>Drupal upgrade tip: Converting from Event module to CCK Date</title>
    <link rel="alternate" type="text/html" href="http://pingv.com/blog/alasda/2008/drupal-upgrade-tip-converting-event-module-cck-date" />
    <id>http://pingv.com/blog/alasda/2008/drupal-upgrade-tip-converting-event-module-cck-date</id>
    <published>2008-12-23T14:09:15-06:00</published>
    <updated>2008-12-23T14:09:22-06:00</updated>
    <author>
      <name>alasda</name>
    </author>
    <category term="Calendar Module" />
    <category term="CCK" />
    <category term="code" />
    <category term="convert" />
    <category term="Date" />
    <category term="Date Module" />
    <category term="Drupal" />
    <category term="Event Module" />
    <category term="upgrade" />
    <category term="Views" />
    <content type="html"><![CDATA[<p> If you're upgrading your site from Drupal 5 to Drupal 6 and were previously using the event module, you have probably realized that a lot of the supporting modules that made the event module functional (such as Event Views) have fallen by the wayside.  Well, as luck would have it, much (if not all) of the functionality that the event module provides can be re-created using CCK date fields, views and the calendar module.  So the only task that remains is to get your existing event content migrated over into usable CCK fields, and then configure your views to display them into a calendar display.</p>
<p>While there are undoubtedly other approaches to achieve this end, this is a relatively quick and painless path to get the features you want up and running.</p>
<p>You'll require the following D6 supporting modules:<br />
CCK - <a href="http://drupal.org/project/cck" title="http://drupal.org/project/cck">http://drupal.org/project/cck</a><br />
Date - <a href="http://drupal.org/project/date" title="http://drupal.org/project/date">http://drupal.org/project/date</a><br />
Views - <a href="http://drupal.org/project/views" title="http://drupal.org/project/views">http://drupal.org/project/views</a><br />
Calendar - <a href="http://drupal.org/project/calendar" title="http://drupal.org/project/calendar">http://drupal.org/project/calendar</a></p>
<p>Install and enable the latest revisions of these modules.</p>
<p>Identify the content type or types currently on your site which are used by events.  The process differs slightly depending on whether the resulting CCK date fields will be located in only one content type, or shared between multiple types.</p>
<p>Through the CCK interface, create new date fields in your existing event content type.  These are the fields into which the old event information will be migrated .  For the purposes of this document, I'll call them "eventstart" and "eventend".</p>
<p>If you have only one content type for events, your new fields will be created in the mysql table corresponding to that type.  For example, if your content type was called wine_tastings, a table called content_type_wine_tastings will exist in your database, and the fields field_eventstart_value and field_eventend_value will exist in this table.</p>
<p>If you're sharing the eventstart and eventend fields between multiple content types, new tables will be created to house this data.  In this example, the tables would be called content_field_eventstart and content_field_eventend.</p>
<p>Now with a little php and mysql magic, we can populate the new field data from the event_start and event_end fields from the original event table.  Because the date information is stored in slightly different formats, a little bit of transformation is required.  Create a php script like the example below, and execute from the command line.  This example was constructed using shared date fields across multiple content types.</p>
<p><b>Remember to ALWAYS back up your database before performing any operations like this!</b></p>
<div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// You backed up your database, right?</p>
<p>// Set up the mysql connection<br />// Drupal's bootstrap function may be substituted here<br />// require_once '/path/to/drupal/includes/bootstrap.inc';<br />// drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);<br /></span><span style="color: #0000BB">$con </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">, </span><span style="color: #DD0000">'yourdbusername'</span><span style="color: #007700">, </span><span style="color: #DD0000">'yourdbpassword'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">mysql_select_db</span><span style="color: #007700">(</span><span style="color: #DD0000">'yourdbname'</span><span style="color: #007700">, </span><span style="color: #0000BB">$con</span><span style="color: #007700">);</p>
<p></span><span style="color: #FF8000">// Cycle through all the records in the event table <br /></span><span style="color: #0000BB">$q </span><span style="color: #007700">= </span><span style="color: #DD0000">'select * from event'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$r </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$q</span><span style="color: #007700">);<br />while (</span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_fetch_assoc</span><span style="color: #007700">(</span><span style="color: #0000BB">$r</span><span style="color: #007700">)){</p>
<p></span><span style="color: #FF8000">// Transform the date information<br />// CCK date format: 2008-12-10T00:00:00<br />// event date format: 2006-11-13 15:00:00<br />&nbsp; </span><span style="color: #0000BB">$startdate </span><span style="color: #007700">= </span><span style="color: #0000BB">preg_replace </span><span style="color: #007700">(</span><span style="color: #DD0000">"/ /"</span><span style="color: #007700">, </span><span style="color: #DD0000">'T'</span><span style="color: #007700">, </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'event_start'</span><span style="color: #007700">]);</p>
<p></span><span style="color: #FF8000">// Populate the new field for eventstart<br />&nbsp; </span><span style="color: #0000BB">$q2 </span><span style="color: #007700">= </span><span style="color: #DD0000">'update content_field_eventstart set field_eventstart_value="'</span><span style="color: #007700">. </span><span style="color: #0000BB">$startdate </span><span style="color: #007700">. </span><span style="color: #DD0000">'" WHERE nid="'</span><span style="color: #007700">. </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'nid'</span><span style="color: #007700">] . </span><span style="color: #DD0000">'"'</span><span style="color: #007700">;<br />&nbsp; if (!</span><span style="color: #0000BB">$r2 </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$q2</span><span style="color: #007700">)){</p>
<p></span><span style="color: #FF8000">// Don't continue if anything goes south<br />&nbsp;&nbsp;&nbsp; </span><span style="color: #007700">exit (</span><span style="color: #0000BB">$q2 </span><span style="color: #007700">.</span><span style="color: #DD0000">" failed!\n"</span><span style="color: #007700">);<br />&nbsp; }</p>
<p></span><span style="color: #FF8000">// Perform the same transformation and data population for the end date<br />&nbsp; </span><span style="color: #0000BB">$enddate </span><span style="color: #007700">= </span><span style="color: #0000BB">preg_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">"/ /"</span><span style="color: #007700">, </span><span style="color: #DD0000">'T'</span><span style="color: #007700">, </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'event_end'</span><span style="color: #007700">]);<br />&nbsp; </span><span style="color: #0000BB">$q3 </span><span style="color: #007700">= </span><span style="color: #DD0000">'update content_field_eventend set field_eventend_value="'</span><span style="color: #007700">. </span><span style="color: #0000BB">$enddate </span><span style="color: #007700">.</span><span style="color: #DD0000">'" WHERE nid="'</span><span style="color: #007700">. </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'nid'</span><span style="color: #007700">] .</span><span style="color: #DD0000">'"'</span><span style="color: #007700">;</p>
<p></span><span style="color: #FF8000">// Once again, terminate the operation if the query fails<br />&nbsp; </span><span style="color: #007700">if (!</span><span style="color: #0000BB">$r3 </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$q3</span><span style="color: #007700">)){<br />&nbsp;&nbsp;&nbsp; exit(</span><span style="color: #0000BB">$q3 </span><span style="color: #007700">.</span><span style="color: #DD0000">" failed!\n"</span><span style="color: #007700">);<br />&nbsp; }<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
<p>Once you've got these fields populated, you should check an existing node to verify that the information has been correctly populated.  Navigate to one of your event nodes, and select edit.  You should see both the legacy event date information and the new CCK fields populated with the start and end dates.</p>
<p>If this all checks out, browse to the modules page and disable the events module.  You are now free to uninstall the event module and purge any vestigial tables.</p>
<p>Congratulations!  You have converted your event nodes to a more flexible CCK/Date setup.  These fields are now available for use in views using the calendar module! </p>
    ]]></content>
  </entry>
  <entry>
    <title>pingVision&#039;s Drupal services go Platinum as Acquia Partner</title>
    <link rel="alternate" type="text/html" href="http://pingv.com/blog/laura/2008/pingvisions-drupal-services-go-platinum-acquia-partner" />
    <id>http://pingv.com/blog/laura/2008/pingvisions-drupal-services-go-platinum-acquia-partner</id>
    <published>2008-12-12T07:37:59-06:00</published>
    <updated>2008-12-12T07:53:28-06:00</updated>
    <author>
      <name>Laura</name>
    </author>
    <category term="About" />
    <category term="Press" />
    <category term="Partners" />
    <category term="Acquia" />
    <category term="Dries Buytaert" />
    <category term="Drupal" />
    <category term="Jay Batson" />
    <category term="Views" />
    <content type="html"><![CDATA[<p> <a href="http://pingv.com/services"><img src="http://pingv.com/files/BadgePlatinum.png" alt="Acquia Platinum Partner badge" title="pingVision is an Acquia Platinum Partner" /></a><br />
It happened several weeks ago, and the <a href="http://www.prweb.com/releases/2008/12/prweb1613654.htm">official announcement</a> went out <s>yesterday</s> Wednesday, so I figured it's time to blog it: pingVision is an <a href="http://acquia.com/partners">Acquia Platinum Partner</a>, offering IA/TA, web design, development, deployment, performance tuning and consulting services for sites built using Acquia Drupal<sup class="glossary-indicator" title="Acquia Drupal is a commercially supported distribution of Drupal, comprised of Drupal core, plus some contributed modules – all vetted by Acquia, a company co-founded by Drupal creator Dries Buytaert. The Acquia Drupal code is available for free under the same General Public License that governs the Drupal code. Acquia Drupal provides a solid foundation for subscription to the Acquia Network, which provides streamlined code updates functionality and other support. See http://pingv.com/services/acquia-drupal"><a href="http://pingv.com/glossary/10#term314" title="Acquia Drupal is a commercially supported distribution of Drupal, comprised of Drupal core, plus some contributed modules – all vetted by Acquia, a company co-founded by Drupal creator Dries Buytaert. The Acquia Drupal code is available for free under the same General Public License that governs the Drupal code. Acquia Drupal provides a solid foundation for subscription to the Acquia Network, which provides streamlined code updates functionality and other support. See http://pingv.com/services/acquia-drupal" class="glossary-indicator">*</a></sup>.</p>
<p>Acquia truly escalated the Drupal world when it came out with its commercially supported distribution of Drupal. Nothing is lost. It's all gain. Because Acquia Drupal is still Drupal, still free, still licensed under the GPL. And it's co-founded by Drupal creator Dries Buytaert, meaning it's not at all likely to go off on its own fork. (Dries not only wouldn't want to, it wouldn't make business sense in the open source ecosystem.)</p>
<p>Check out the <a href="http://acquia.com/products-services/acquia-drupal-modules">community modules</a> included in Acquia Drupal:</p>
<ul>
<li>Admin Menu</li>
<li>Advanced Help</li>
<li>CCK</li>
<li>Fivestar</li>
<li>Google Analytics</li>
<li>Image and ImageCache</li>
<li>Pathauto</li>
<li>Printer, e-mail and PDF versions of pages</li>
<li>Tagadelic</li>
<li>and, of course, Views, the powerful query builder developed by Earl Miles that enables non-coders to create custom filtered dynamic blocks and pages of content.</li>
</ul>
<h3>A new support resource</h3>
<p>The <a href="http://acquia.com/products-services/acquia-network">Acquia Network</a> of support offers some new reassurance to website owners and operators who might be a bit leery of venturing into the deep end of the open source pool.</p>
<p>You can get:</p>
<ul>
<li>Software update management</li>
<li>System profile management</li>
<li>Automated spam blocking with Mollom</li>
<li>Heartbeat uptime monitoring</li>
<li>Code modification detection</li>
<li>Remote cron activation</li>
<li>Online documentation</li>
<li>Site usage statistics</li>
</ul>
<p>Acquia also has a tech support team available via web, email and telephone, depending upon subscription level.</p>
<p>We're delighted to offer <a href="http://pingv.com/services">Acquia Drupal services</a>. It's been a real pleasure working with the Acquia team these past few weeks. We look forward to many years working together to help spread Drupal around the world.</p>
<h3>From the press release</h3>
<blockquote><p>Acquia, provider of the commercially supported distribution of the popular Drupal social publishing system, today announced that pingVision, the Drupal web developer behind websites such as PopSci.com and Pregnancy.org, has been selected to join the Acquia Partner Program as a Platinum service provider. pingVision has received substantial and sustained recognition for its Drupal technology solutions, and is fully committed and fully equipped to deliver sustainable business growth with Acquia-powered solutions.</p>
<p>"pingVision has a strong reputation for its leading technology solutions and has shown a deep commitment to furthering Acquia's vision. We're excited to have pingVision join the Acquia Partner Program as a platinum member," said Jay Batson, Acquia co-founder and CEO.</p>
<p>pingVision has won awards for design and development of Drupal-powered websites for clients including Bonnier, E.W. Scripps &amp; Co., Stanford University and BlogHer, and is one of the few companies providing turnkey services for enterprise Drupal websites.</p>
<p>"Acquia Drupal and the Acquia Network are ideal for our clients of all sizes, who want that added level of support," said Laura Scott, co-founder and President of pingVision. "And by providing a fully supported distribution of Drupal for a website's foundation, Acquia affords us the opportunity to focus on the custom development, integrations and theming at the core of our business."</p>
<p>The Acquia Partner Program helps organizations of all sizes identify Drupal service providers with the expertise, experience and services to meet their unique website requirements. As an Acquia Platinum partner, pingVision can deliver custom solutions built on Acquia Drupal that connect to the Acquia Network for additional site management and network services, as well as technical support. Working together, Acquia and pingVision are focused on extending the reach of Drupal into new markets and application areas.</p>
<p>For more information, please visit: <a href="http://acquia.com/partners" title="http://acquia.com/partners">http://acquia.com/partners</a>, and http://pingv.com.</p></blockquote>
<p>And be sure to say hello! </p>
    ]]></content>
  </entry>
  <entry>
    <title>Drupal&#039;s Views module unleashes new power for website administrators</title>
    <link rel="alternate" type="text/html" href="http://pingv.com/blog/matt-tucker/2008/drupals-views-module-unleashes-new-power-website-administrators" />
    <id>http://pingv.com/blog/matt-tucker/2008/drupals-views-module-unleashes-new-power-website-administrators</id>
    <published>2008-10-27T17:37:29-05:00</published>
    <updated>2008-11-13T15:53:56-06:00</updated>
    <author>
      <name>Matt Tucker</name>
    </author>
    <category term="Actions" />
    <category term="Drupal" />
    <category term="NodeQueue" />
    <category term="theming" />
    <category term="Triggers" />
    <category term="Views" />
    <category term="workflow" />
    <content type="html"><![CDATA[<p>After the initial official release of <a href="http://drupal.org/project/views">Views 2</a> nearly two weeks ago, we felt the need to give an official rundown of how we have incorporated some of its features into our production sites. There really are too many new features to discuss in one blog post, but I will try to cover a few new features for site administrators, developers, and themers.</p>
<!--break-->
<h3>What is Views?</h3>

<p>If you're not familiar with Views already, it can be a bit challenging to explain. Views is the most <a href="http://drupal.org/project/usage">actively used</a> contributed module in the Drupal repository. On the most basic level, it is used to create lists of data. The majority of a website is built upon two concepts: the first being data, the second being presentation of this data. It is for this reason that views is a vital element of many sites.</p>

<p>Views gives you the option to filter the data outputted by a variety of options -- including but not limited to: node type, author, taxonomy term. It also allows you to sort by a variety of different options, including: post date, updated date, number of page views, etc. The list of data can be unformatted or outputted via a table, grid, list, river-of-news, etc.</p>

<p>Using Views, one can create countless lists of data such as: 
  <ul>
    <li>River of news</li>
    <li>Image gallery</li>
    <li>User lists</li>
    <li>Highest-rated content</li>
  </ul>
</p>

<p>And all this can be done without touching a bit of code.</p>

<h3>A Greatly Improved User Interface</h3>

<p>The most obvious change with the Views 2.0 is the user interface itself. What used to be thousands of pixels in height now fits before the first page fold in a completely revamped interface.</p>

<p><img src="/files/images/views2-user_interface.preview.png" alt="Views 2 User Interface" style="margin-left: -95px; float: left" /></p>

One of the most useful new features is the ability to create multiple displays within one view. Often, one needs to create a block, page, and feed of relatively the same data. Not only does Views 2 give you this functionality, but it also presents the controls in a unified interface that allows you to quickly change configuration settings between multiple displays.<p>
  
<p>For example, if you had a page and a block display both showing the most recent 5 blog entries posted to your site, you could simply change the ‘Default’ display to show the most recent 10 entries, and that setting would trickle down to all other displays. This functionality alone decreases the amount of time needed to create and update views drastically. (Of course, one can set a display to override the default display on a per-configuration setting basis.)</p>

<p>Not only has the interface for creating and editing views improved, but you can now create views which are more complex. To begin, no longer is Views node-centric - meaning that one can create lists of almost any data stored in the database, from users, to comments, files, revisions, and taxonomy terms. This opens up a whole new use for views, which, before, was reserved for custom queries.</p>

<h3>Views as Attachments</h3>

<p>Another new feature of Views is the ability to attach view display to another. By creating a display type of ‘Attachment,’ one has the option to amend or prepend one list of data with another.</p>

<p>For example, creating a gallery-type view which displays the most recent image enlarged with the description to the right, and the next six most recent images’ thumbnails below is entirely too easy with Views 2 and <a href="http://drupal.org/project/imagecache">imagecache</a>. Simply create a display which outputs two fields: the first being the image using a large imagecache preset, the second being the node body (or other description field). Then, create an attachment display, which displays a total of 6 nodes offset by 1 (to account for the first large image), and set the imagecache preset to be a smaller thumbnail. Then, simply select your attachment display to propend to your first display, add a bit of CSS to float the large image to the left and bingo, you have a single view that looks like this:
<img src="/files/images/views2-example_attachment.preview.png" alt="Views 2 - Example Attachment" style="margin-left: -95px; float: left" /><br /><em>Sample images' source: commons.wikimedia.org</em>
</p>

<h3>Relationships in Views, and Advanced Help</h3>

<p>Another fantastic feature is the ability to define relationships in a view. A relationship allows you to expand the original query to include additional objects.</p>

<p>For example, if you are using a <a href="http://drupal.org/project/nodequeue">nodequeue</a> to order your nodes, you might want to create a view which is sorted by order within the nodequeue. Simply add a relationship to the nodequeue within the views interface, and you will see a new sort option appear: <img src="/files/images/views2-example_relationship_nodequeue.preview.png" alt="Views 2 - Example Relationship - Nodequeue" style="margin-left: -95px; float: left" /></p>
 
<p>You will notice notice in the above screenshot that there are question-mark icons next to Relationships and Sort criteria. These were added via the <a href="http://drupal.org/project/advanced_help">Advanced Help</a> module, which makes accessing help much easier. For a feature rich module such as views, this functionality is extremely helpful.</p>

<h3>Easy Views Theming</h3>

<p>Theming a 1.0 View used to be a daunting task. Figuring out which theme functions to override was often difficult and, simply put, was too complicated for beginning themers. Now, Views 2.0 uses a template-based theming system. All of the information as to which <code>tpl</code> files to create is accessible through the user interface under Base Settings > Theme > Information. Moving to a template-based system makes the life of a themer much brighter.<p>

<p>Although all of the discussed features are quite wonderful, the most useful addition to Views 2 is, undoubtedly Live Preview. No longer do you have to save your view, which tabs, and refresh. Instead, everything is handled on one screen, allowing you to work more efficiently.</p>

<h3>Views + [other Drupal modules]</h3>

<p>There are many contributed Drupal modules that integrate well with Views, making Views all the more powerful and useful.</p>

<p>For example, we are using Views to handle some complex workflows. With the combination of <a href="http://drupal.org/project/workflow">Workflow</a>, Actions, Triggers, <a href="http://drupal.org/project/nodequeue">NodeQueue</a>, and <a href="http://drupal.org/project/views">Views</a>, one can create a feature-rich site that handles complex content creation workflows demanding moderation, approval, and promotion stages. Workflow integrates seamlessly with Views, allowing you to create lists of all nodes in a certain state. Integration of Workflow with Views also adds many other useful filters, sorts, and fields.</p>

<p>We have also used Views to create a custom search page with customizable sort options. It seems that almost every week we find a new use for Views that shortens our time spent on these types of tasks, allowing us to spend more time making sites even more functional than before.</p>

<h3>A Valuable Drupal Toolset Created by a Most-Valuable Drupal Player</h3>

<p>A special shout out from all of us at pingVision to Earl Miles (<a href="http://drupal.org/user/26979">merlinofchaos</a>) who was recently voted <a href="http://www.packtpub.com/article/open-source-cms-most-valued-people-announced">Drupal's MVP</a> by Packt Publishing mainly for creating such a wonderful contribution to the Drupal community.</p>    ]]></content>
  </entry>
  <entry>
    <title>Combining different views using views offsets</title>
    <link rel="alternate" type="text/html" href="http://pingv.com/blog/slaug/200802/view-offsets" />
    <id>http://pingv.com/blog/slaug/200802/view-offsets</id>
    <published>2008-02-22T11:07:36-06:00</published>
    <updated>2008-02-22T11:07:36-06:00</updated>
    <author>
      <name>slaug</name>
    </author>
    <category term="code" />
    <category term="Drupal" />
    <category term="Views" />
    <content type="html"><![CDATA[<p> We recently had a client that wanted to have two different teaser treatments for a node type on their homepage: The first node would show more content, while the other nodes would have less content displayed. This is common for displays where you want, for example, a highlighted top post with more abbreviated lower posts. </p>
<p>We approached this using two views. The top view would return the top node of the view, while the second view would return everything but the most recent item, while displaying different teasers. The first view was easy: simply the most recent node of that type that had been published.</p>
<p>The second view, however, was created by using two functions from the views module and placed in the <code>page-front.tpl.php</code> file:</p>
<ol>
<li><code>views_get_view($view_name)</code></li>
<li><code>views_build_view($type, &amp;$view, $args = array(), $use_pager = false, $limit = 0, $page = 0, $offset = 0, $filters = NULL)</code></li>
</ol>
<p>We used  <code>views_get_view()</code> to get the view object for the view and set it to a variable:</p>
<div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$second </span><span style="color: #007700">= </span><span style="color: #0000BB">views_get_view</span><span style="color: #007700">(</span><span style="color: #DD0000">'Secondary_topics'</span><span style="color: #007700">); <br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
<p>Next we used the <code>views_build_view()</code> to display the view on the home page:</p>
<div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">print </span><span style="color: #0000BB">views_build_view</span><span style="color: #007700">(</span><span style="color: #DD0000">'embed'</span><span style="color: #007700">, </span><span style="color: #0000BB">$second</span><span style="color: #007700">, array(), </span><span style="color: #0000BB">FALSE</span><span style="color: #007700">, </span><span style="color: #0000BB">5</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
<p>We stated the type as <code>embed</code> because the view is being embedded in a page. The the next parameter, <code>$second</code>, is the views object, which was returned by the <code>views_get_view</code> function.</p>
<p>To achieve the goal of getting five teaser views starting at the second most recent topic, we set the <code>$limit</code> parameter to 5 and the <code>$offset</code> parameter to 1. </p>
<p>For the other view that only displays the most recent node topic we used the same two functions, but set the <code>$limit</code> parameter to 1 in the <code>views_build_view</code> function:</p>
<div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$first </span><span style="color: #007700">= </span><span style="color: #0000BB">views_get_view</span><span style="color: #007700">(</span><span style="color: #DD0000">'Front_Page'</span><span style="color: #007700">);<br />print </span><span style="color: #0000BB">views_build_view</span><span style="color: #007700">(</span><span style="color: #DD0000">'embed'</span><span style="color: #007700">, </span><span style="color: #0000BB">$first</span><span style="color: #007700">, array(), </span><span style="color: #0000BB">false</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
<p>We placed both of these steps into the <code>page-front.tpl.php</code> template in the appropriate places to display the content on the page and in the order that is needed.  </p>
<p>Now the new issue is this: both contents look the same because the views are both calling the same <code>node.tpl.php</code> file and there is no flag to check for which view is being used.  </p>
<p>To resolve this issue we used the global variable <code>$current_view</code> as a flag. The <code>$current_view</code> variable is an object that contains the name of the view being used (<code>$current_view-&gt;name</code>). We placed the <code>$current_view</code> variable at the top of the <code>node.tpl.php</code> template file.  Next we used a conditional statement (if..elseif..else) to have the <code>node.tpl.php</code> file display different content for each view on the same page.   </p>
<div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /> </span><span style="color: #007700">global </span><span style="color: #0000BB">$current_view</span><span style="color: #007700">; <br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
<p>This displays content for the first topic view on the front page, but not for the other view on the front page:</p>
<div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php </span><span style="color: #007700">if((</span><span style="color: #0000BB">$current_view</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">name </span><span style="color: #007700">== </span><span style="color: #DD0000">'Front_Page'</span><span style="color: #007700">) &amp;&amp; </span><span style="color: #0000BB">$is_front</span><span style="color: #007700">): </span><span style="color: #0000BB">?&gt;</span></span><br />This will only display in the first view on the front page.<br /><span style="color: #000000"><span style="color: #0000BB">&lt;?php </span><span style="color: #007700">endif; </span><span style="color: #0000BB">?&gt;</span></span></code></div>
<p>I hope this helps other Drupal users. If anyone else has come across this and did it a different way, please share. </p>
    ]]></content>
  </entry>
</feed>
