How to conditionally hide a field in a drupal view? - drupal-6

I have two fields that I want to render but I only want the second one to display when the first one is empty. Short of overriding the field in a template file, can I do this using functionality in the built in views functionality?

For views 3 , drupal 7
Desired output - Show field1 if field2 is empty.
Add both fields to view in field1, field2 order and select field1 checkbox "exclude from display".
Go to field2 and configure "Show No results behavior". Add field1 replacement pattern e.g [field1] and select "Count the number 0 as empty" , "Hide if empty" and "Hide rewriting if empty".
Now this will produce if else functionality for these two fields.

Add the field that you want to show. Select "exclude from display".
Add the field that you want to control if you show the previous one. Select "rewrite output". Use the token replacement for showing the previous field. Mark "Hide if empty"
There is no three.
PS: Quoted option texts may be not the right ones (I'm looking at a translated site), but you get the idea.

I would normally use the views_customfield module for this kind of thing. Add a third field to your view that is a php customfield, and exclude your second field from display. You can then write a really quick PHP snippet in the customfield that checks to see if the first field is empty and prints out the second field if it is.

You can do this easily by the following steps (I've tried it in drupal 7):
Add both fields
make the first one invisible (exclude from display)
in the second field go to no result behavior tab.
write the token of the first field (example: [field_name]).
It should work, I hope it will work with you

My solution for showing field_1 for English version and field_2 for translated version:
With use of panels:
Make two copies of the view by adding another display to the view.
In the original view display you remove or exclude from display field_2, in the second display you remove field_1.
In your panel you add both of your view displays as a panel panes.
For the first view display pane add Visibility rule -> User:language -> English.
For the second view display pane add Visibility rule -> User:language -> Your_second_language.
It looks complicated, but it's really simple for people familiar with panels and views.
This solution requires no code changing nor knowledge of theming.

You can kind of massage it into working with contemplate. You could do something like this:
<?php
if(empty($node->field_foo[0]['view'])){ ?>
<?php print $node->field_bar[0]['view'] ?>
<?php } ?>

Related

Force user to select only one value from filter spotfire

Is it possible to force the user to select only one value from a filter ?
For a radio button filter as below, is it possible to remove the buttons all & none and make sure that only one Choice is selected ?
you cannot change the existing filter features or functionality without developing a custom extension for a new filter control.
that said, you can certainly emulate a filter using what's called a Property Control and a Data Limiting Expression. for single selection, you're stuck with either a Dropdown control or a Listbox (single select) control.
you would need to...
create a Text Area Visualization on the page somewhere
insert a Listbox or Dropdown Property Control into the Text Area Visualization
create a Document Property with the same data type as your filter column and associate it to the Property Control. you can set this to Unique Values in Column or write in your own Fixed values.
open the Properties dialog on the visualization you'd like to filter and navigate to the Data page
scroll down to Limit Data Using Expression and use an expression like [MyFilterColumn] = "${MyDocumentProperty}" (quotes are required for string values; if numeric then omit quotes)
Please add this CSS in the HTML page of the spotifre to remove all and none
.ColumnFilter .sf-element-filter-item:last-of-type { display:none; }
.ColumnFilter .sf-element-filter-item:first-of-type { display:none; }
Another way to force the users to select one option is to add a Show/Hide in the visualization like this: Hide if UniqueCount([Field]) is greater than 1

In Google Analytics, how do I remove queries that start with a ? but keep the content before it

I have an example here where my All Pages is showing /index.php?from=http://share-buttons.xyz/ as a page hit.
I want this to report only as /index.php
I applied a search and replace filter of this:
^[^?]+(\?.*)
and the replace field I left blank.
That however removes the entire entry so it's like it isn't tracked at all.
Is there a way to do what I want?
Thanks!
The easiest way is to go to your view settings. Enter "from" and any other parameter you want to exclude in the "Exclude URL Query Parameters" box (separated by commas). No need to set up filters.

Gravity forms - merging values

Need some help with Gravity forms. I need to have a field, that is a merge of values ,that user has previously selected.
So, if a user has selected 3 different fields wth values of 1)XYY, 2)YYX,3)YYZ I do not need a sum, just a plain merge, in form of XYY.YYX.YYZ, or anything like that.
Could that be acomplised with some merging tags, or dynamically population?
Thanks
Of course;
You should create two different forms.
Collect data with field1-field2-field3, they can be single line text, number, date or anything. In the advanced tab of field settings, write a parameter name for each one, like field1-field2-field3.
In the second form create a single line text, in the advanced tab of field settings check "dynamically populate field" and write your parameters like field1.field2.field3.
In form1 settings->confirmations->redirect URL line, write your form2 page url where you added form2. Select "Pass field data via query string" and add your parameters like field1={fieldname:1}&field2={fieldname:2}&field3={fieldname:3}
When you submit form1, your form2->single line text field will capture the parameters as you wish.
This is possible with Gravity Forms Populate Anything by...
Add whatever type of field you'd like to use to capture the combined.
Set the Default Value to the merge tags of your 3 fields: #{Field A:1}.#{Field B:2}.#{Field C:3}.
That's it.
Edit: Updated screenshot for Gravity Forms 2.5 and updated merge tags to use the # to make them "live".

How do I create a pager for a view that shows the alphabet instead of numbers?

I have a need to have an alphabetical pager for a view. I didn't see any of the samples or the custom pager that addresses this. I would think that this would be a pretty common thing.
MJ
I'm not quite sure what you really mean by an "alphabetical pager", but I assume you might be looking for some kind of alphabetical navigator like we have it in the personal NAB inside the Notes client, right?
If so you're not really looking for a pager but for an alphabetical view filter. Here's one way to get there:
create a panel, give it a distinctive ID like "viewContainer" or
something. Put your view panel into the panel; of course the view's main sorting order must be alphabetical
create a 2nd panel above "viewContainer", no ID necessary here
put a repeat inside this new panel and bind it to a new JavaScript array, like that:
new Array("a", "b", "c", ... , "x", "y", "z");
enter a collection name for the repeat, like "letter"
put a link control inside the repeat. The link's label will be
computed to the repeat's collection name, i.e. "letter".
assign an onclick event to the link setting a sessionScope variable to the current collection name's value, like that:
sessionScope.filter = letter;
set the event's refresh mode to partial so that it refreshes your viewContainer panel
highlight your view control inside the viewContainer. In its data properties look for the property field labelled "Filter by column value" and make it computed. Enter this code:
sessionScope.filter;
That's it.
Edit:
of course you can build the repeat's datasource array dynamically from the view itself. So, instead of building that static a-to-z array you could also use something like this:
#Unique(#Left(#DbColumn(#DbName(), "yourLookupView", viewColNumber), 1));
That should return an array only containing those letters that really are in your view.
Also you could another static link control outside the repeat resetting the filter to show all entries. It would be built like the repeated link with the onclick event calling this code:
sessionScope.filter=null;
Enjoy!
I would go for this: make a view categorized by formula #Left( value; 1). Then render result of #DbColumn as pager by repeat or some ExtLib component (links list, navigator, menu). Each link will either limit shown view to "single category" or jumps to "starts with" character.

Dynamic Layouts in Filemaker

First off I am new to FM but I have a good handle on the basics. What I need to do is this - in a contact information type layout I want to be able to alter the layout based on a specific field. Ex. When the record is brought up, the background of the layout will change colors for a client, another for vendor, etc.
I tried to change a label based on a field, with no success. My guess is that the layout is static and only the data fields change.
We use FM Pro.
Thanks,
Mark
FileMaker layouts are static, but there are still some things you can do to alter the layout based on the values of fields:
Calculation Fields
If you want the data shown in an area to change, you can use a Calculation field. A typical example of this would be a status field. To do this you would add a new field to your table and use enter a calculation on that field like:
Case (
IsEmpty(myTable::myField) ; "Please enter a value for myField." ;
myTable::myField = "wrong value" ; "Please enter a correct value for myField." ;
"Everything seems okay."
)
Conditional Formatting
To make things like background color change you can use a conditionally formatted field. I will typically add an empty numeric field (for this example we'll call it emptyField) and set it so that it can't be edited during modification.
If you place emptyField on your layout, below all the other fields and disallow the user to enter the field in either Browse or Find mode, you can then use conditional formatting to change the field's color.
Portal Hiding
You can use this technique when you want some elements of your UI to disappear when they aren't needed. For example, if you want a "submit" button to appear only when all of the records on a field are filled out.
To use this technique I will usually create a Calculated number field, called ReadyForSubmit, on the original table and give it a logical calculation like:
not IsEmpty(field1) and ... and not IsEmpty(fieldN)
(Note that the value of the above function would be 1 or 0)
I will then create a new Support table in my database and add to it a field One with a calculated value set to 1.
I will then make a relationship between myTable::readyForSubmit and Support::One.
On the layout, create a portal with one row. Put your Submit button in that layout. Now, when readyForSubmit calculates to 1 the button will appear. When it calculates to 0 the button will be hidden.
Hidden Tab Browser
Finally, you can use a tab browser where you set the title font size to 1 point, hide the border, and control the browser programmatically. You can use this for having different field arrangements for different types of records. To do this you would first give an Object name to each tab of the tab browser, say Tab1, Tab2, Tab3.
Then you would add a script, goToTab, with the logic for when you want to go to each tab. Say:
If (myTable::myField = "corn")
Go to Object (Tab1)
Else If (myTable::myField = "squash")
Go To Object (Tab2)
End If
You would then use Script Triggers to run goToTab when On Record Load.
With the release of filemaker 13 there may be another way to do this. You could use a slide control, name the panels in the control, and conditionally switch to the correct panel based on the record type.
you would drop the appropriate fields for the record type in each panel.
http://help.filemaker.com/app/answers/detail/a_id/12012/~/using-slide-controls-and-slide-panels-in-filemaker-pro

Resources