Hi, I've been searching day and night for a solution to my issue and can't seem to find my situation on this or other forums.

Basically I'm using Gmap with views and it works the way it should, map displays fine. I also customized the views-view-fields.tpl.php file to suit my content type.
But the problem i have is that when the marker is clicked on, it displays this content type's display. There are too many fields appearing in that
infowindow.

I was wondering if there's a way I can point to another file, views-view-fields2.tpl.php so that I can just display the content that I want.

In other words, I have views-view-fields.tpl.php which outputs..

Name
Location
City
State
Country

in that infowindow. But I would like to output only..

Name
Location

using a file that I create called views-view-fields2.tpl.php.

I don't know what to modify so that I can basically detour the view to my customized file.

I hope someone can point me to the right direction.

Thanks,
John

Comments

pbarnett’s picture

Since views-view-fields.tpl.php is passed the view as a variable ($view) can't you simply add some conditional code depending on the value of $view->name ?

Pete.

johnlee80’s picture

hi pbarnett,

Thanks for your response. Just for your reference, I'm just a beginner with php..

I see, so your saying that I can use a conditional statement like this:

If views-view-field.tlp.php file contains 'this data'
  then go to 'this_file.tpl.php'

Forgive my lack of proper use of commands above..If I can use this conditional statement, would it go directly in the views-view-fields.tpl.php file or would it go into the template.php file?

- John

pbarnett’s picture

Hi John!

There are so many ways to do this... I was suggesting that you change the views-view-field.tpl.php such that it has an if.. statement in it that checks for the view name being the view you want to customise; you could say something like

if ($view->name == 'your_view_name') {
  // Your specific code, copied and modified from the original template code
}
else {
  // the default template code
}

instead of doing anything more complicated. Note the curly brackets!

Are you new to PHP, or programming in general?

Your code would simply have to check the field name and display it if it was one you wanted, so to speak.

This is hardly a detailed explanation, and not necessarily the best way to do it, but it would definitely work...

Pete.

johnlee80’s picture

Pete,

Thanks! that did it!

Well, needed to modify the if/else a little bit, but this did the trick.

Thanks again!