3

Mock: Mock Site: http://www.mastersfunds.com.php5-23.dfw1-2.websitetestlink.com/funds-and-performance/equity-fund

Brief: The mock has the title with 2 font styles. The first part is in blue text and the fund/ticker is in a smaller, light gray font.

Is there a way to use VIEWS to display the TICKER font/html directly after the Title as displayed in the mockup? What VIEWS settings would I use?

4
  • This should be fairly easy to do, but right now, it looks like it's a QuickTab. Do you want it to be a View instead?
    – g_thom
    Aug 2 '11 at 20:18
  • Also, is the 'ticker' a CCK field, or will you be adding that manually?
    – g_thom
    Aug 2 '11 at 20:19
  • Well right now the TITLE for the QUICK-TAB can only take 1 style. I want to show a custom HTML snippet AFTER the quick-tab title so the ticker can be a smaller/gray style instead of the style of the h2 title.
    – KevinOrin
    Aug 2 '11 at 20:39
  • This is only my 3rd or 4th Drupal site and I'm not too familiar with CCK. The ticker is no where yet, I noticed in VIEWs there's an option to add a field AFTER whatever the view is. And that field accepts html.
    – KevinOrin
    Aug 2 '11 at 20:41
1

I think as a relatively new Drupal developer, you could benefit tremendously from getting to know CCK. This will allow you to have flexibility with how fields are laid out and ensure that page layouts remain consistent.

The way you've approached the task, I can think of two ways to get that ticker to show: using jQuery and using a theme function. If you know about template.php and theme overrides, I'd recommend that route. Otherwise, this should be doable with jQuery:

Using jQuery:

Place this in a js file:

$(function() {
    $('#block-quicktabs-fundsperformancetabs h2').append('<div class="ticker">MSILX, ETC</div>');
});

And in your stylesheet

.ticker {
    text-transform: uppercase;
    color: #CCC;
    font-size: 11px;
}

Be sure to include your js file in your theme's info file.

scripts[] = js/custom.js

This has the downside of being 'in the code' instead of editable by the client, but that's where CCK would come in.

1

Views is a tools to query and display data (most of the time nodes). While views is pretty flexible, its main and well documented usages are blocks and pages with data from the database. We don't have that much information, but it doesn't seems like you need to query your database to build a list of items to be displayed. You are rather looking for a way to display the fund/ticker information right after the title of the page.

IMHO, the proper way to do it is to have a hook_preprocess_HOOK implementation for the block.tpl.php template to retrieve the tickers information and store in the $variables array received as argument. Then in this template, display the information right after the title. The tricky part would be retrieving the tickers since you won't have that much information about the block context while in the hook_preprocess_HOOK implementation.

In your custom module .module file or in your theme's template.php

function MODULE_preprocess_block(&$variables) {
  $tickers = get_ticker_from_some_context();
  // Use a custom theme hook to format the tickers
  $variables['tickers'] = theme('tickers', $tickers);
}

In your block.tpl.php

<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>

  <?php print render($title_prefix); ?>
<?php if ($block->subject): ?>
  <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
  <?php if !empty($tickers):?>$tickers<?php endif;?>
<?php endif;?>
  <?php print render($title_suffix); ?>

  <div class="content"<?php print $content_attributes; ?>>
    <?php print $content ?>
  </div>
</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.