2

I have following Html code, I want to rewrite two field .1st is [field_poster_hover_image] and 2nd is [field_team_image] .This is my HTML Code.

 <div class="thumb thumb-type-1">

                <a href="post-page.html" data-logo="images/girls-12s.png">
                  <img src="images/project-3.jpg" alt="project 1" />                </a>           </div>

and I have written code like this but its not working

 <div class="thumb thumb-type-1">

                <a href="post-page.html" data-logo="[field_poster_hover_image]">
                  <img src="[field_team_image]" alt="project 1" />                </a>           </div> 
  • Where have u written the above html code ? – harshal Nov 8 '13 at 7:51
0

You can use hook_views_pre_render(&$view) to rewrite the code .

 function hook_views_pre_render(&$view) {

      switch ($view->name) {
        case 'YOUR_VIEW_NAME':
          foreach($view->result as $key => $value) {
          $value->field_some_element[0]['rendered']['#markup'] = '<div>Your custom markup should be placed here</div>';
    }
        break;
      }
| improve this answer | |
0

You don't want to use [field_team_image] in the src ,just put the [field_team_image] you can get the image and print $data in views custom php field to get the another image to get the url.

| improve this answer | |
  • ok ,it's working but what about image of data-log ? – Nikunj Jagad Nov 8 '13 at 7:51
  • what you want to do with that image?please explain. – Ranjani Nov 8 '13 at 7:58
  • yes I want [field_poster_hover_image] image in the place of data-logo="images/girls-12s.png" – Nikunj Jagad Nov 8 '13 at 8:01
  • Better you print the $data in views php field (to add php field in views you have to install this module if it is drupal 6, drupal.org/project/views_customfield )and get the url of the images dynamically. – Ranjani Nov 8 '13 at 8:05
  • How can I print data ? – Nikunj Jagad Nov 8 '13 at 8:07
0

Using the Image URL Formatter module it is possible to display image. Here is a quote about it (from the module's project page):

... adds a url formatter for image field. Then you can output image url directly.

I had created a content type, and added an image field instance to it. Later on I used views to export the data of this content type. And I wanted to output the data, so I could import it into another Drupal 7 site with the Feeds module. What I needed is the url of the image field, but I could not export the image url directly. That is why I created this small module.

| improve this answer | |
0

You can alter the HTML output at the row level from inside the Views UI:

  1. Add the fields to your view. Settings:

    Create a label - unchecked
    Exclude from display - checked

  2. Otherwise configure each field depending on what kind of output you want. For example, with an image field you might select as your formatter "Image" (to display the rendered image tag) or "Download link" (to display the download path to the file). The latter would be most appropriate in this case.

  3. Add a new field Global: Custom text. Add the mark-up below, only replace [field_myfield1] and [field_myfield2] with the actual tokens for each field, which can be found by expanding Replacement patterns.

//

<div class="thumb thumb-type-1">
  <a href="post-page.html" data-logo="[field_myfield1]"><img src="[field_myfield2]" alt="project 1" /></a>
</div>

//

:) Bonus: If using the node title as the text in your alt attribute, in the above HTML you can replace "project 1" with the [title] token.

| improve this answer | |

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.