CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Block Visibility in Drupal 6 based on CiviCRM gid
Pages: [1]

Author Topic: Block Visibility in Drupal 6 based on CiviCRM gid  (Read 847 times)

jansmath3

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: 4..7.11
  • CMS version: Drupal 7.51
  • MySQL version: 5.5.52
  • PHP version: 5.5.9-1
Block Visibility in Drupal 6 based on CiviCRM gid
April 28, 2014, 10:35:44 am
Hi everyone,
I've been beating my head against the wall and can't seem to figure this out.  I'm hoping someone can help me.

I have several Drupal views that link to contact profiles in CiviCRM.  I have also created a header block that appears above the profile.  This header needs to be visible when the gid=16 but not when the gid=17.

An example path would be civicrm/profile/view?reset=1&id=50826&gid=16 or civicrm/profile/view?reset=1&id=61234&gid=17.

I've tried adjusting the block visibility settings in Drupal using "Show on only the listed pages."  Clearly
Code: [Select]
civicrm/profile/view* won't work and something like
Code: [Select]
civicrm/profile/view*&gid=16 won't work either.

I've also tried to edit using "Show if the following PHP code returns TRUE (PHP-mode, experts only)." with

Code: [Select]
<?php
  
if(arg(0)=='gid=16') {
    return 
TRUE;
  }else {
    return 
FALSE;
  }
?>

and some different variations of this idea.  My code may be incorrect, but I'm looking for any help you can give me.  Thanks for any insight you can give.

This page and its sub-pages is where I found some good info.

https://drupal.org/node/60317

I've also tried using the Drupal 7 solution, which white screens my site from http://forum.civicrm.org/index.php/topic,28727.msg135441.html#msg135441

Code: [Select]
<?php
$match 
= FALSE;
if (
current_path() == 'civicrm/profile/view' && isset($_GET['gid']) && $_GET['gid'] == 16) { $match = TRUE; }
return 
$match;
?>




« Last Edit: April 28, 2014, 11:57:01 am by jansmath3 »

jansmath3

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: 4..7.11
  • CMS version: Drupal 7.51
  • MySQL version: 5.5.52
  • PHP version: 5.5.9-1
Re: Block Visibility in Drupal 6 based on CiviCRM gid
May 21, 2014, 10:17:16 am
Alright.  Maybe this will get a conversation started.  I was able to switch the gid and id in the view, so now theoretically

Code: [Select]
civicrm/profile/view?reset=1&gid=16*

would work in the block visibility.  However, it doesn't.  I saw a post referencing to adding a "/" between the "view" and "?".  However, this doesn't work either.  Does anyone know how to format the special characters so that Drupal properly reads them?

« Last Edit: May 21, 2014, 10:33:21 am by jansmath3 »

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Block Visibility in Drupal 6 based on CiviCRM gid
May 21, 2014, 10:41:04 am
You can get the full URL in PHP by using the global $_SERVER. Then you can write some simple PHP code to check for the gid=16.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

jansmath3

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: 4..7.11
  • CMS version: Drupal 7.51
  • MySQL version: 5.5.52
  • PHP version: 5.5.9-1
Re: Block Visibility in Drupal 6 based on CiviCRM gid
May 21, 2014, 01:15:33 pm
Quote from: Hershel on May 21, 2014, 10:41:04 am
You can get the full URL in PHP by using the global $_SERVER. Then you can write some simple PHP code to check for the gid=16.

Thanks so much for pointing me in the direction I need to go Hershel.  I'm sure I am not correctly coding the visibility settings.  Can you tell me where I'm going wrong?  Thanks again.

Code: [Select]
<?php
$match 
= FALSE;
  if (
substr($_SERVER["REQUEST_URI"], 0) == "/civicrm/profile/view?reset=1&gid=16*")
  { 
$match = TRUE;}
return 
$match;
?>

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Block Visibility in Drupal 6 based on CiviCRM gid
May 21, 2014, 02:40:47 pm
there is quite a long thread here in case you can glean anything from it - but I just use https://drupal.org/project/block_query

which lets me set a block to show at a specific civicrm path and gets around the problem of civi paths having ? in them.

hth
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

jansmath3

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: 4..7.11
  • CMS version: Drupal 7.51
  • MySQL version: 5.5.52
  • PHP version: 5.5.9-1
Re: Block Visibility in Drupal 6 based on CiviCRM gid
May 21, 2014, 08:38:56 pm
Thanks Pete,
I'm not sure where the long thread is about this.  Also, is there a Drupal 6 version of the module?
« Last Edit: May 21, 2014, 08:40:38 pm by jansmath3 »

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Block Visibility in Drupal 6 based on CiviCRM gid
May 21, 2014, 08:45:23 pm
not by looks of it - you might want to read this thread since i forgot to paste last time

http://forum.civicrm.org/index.php/topic,28727.msg122953.html#msg122953
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

jansmath3

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: 4..7.11
  • CMS version: Drupal 7.51
  • MySQL version: 5.5.52
  • PHP version: 5.5.9-1
Re: Block Visibility in Drupal 6 based on CiviCRM gid
May 21, 2014, 08:57:44 pm
Thanks,
It's late, but I'm going check it out first thing tomorrow.

jansmath3

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: 4..7.11
  • CMS version: Drupal 7.51
  • MySQL version: 5.5.52
  • PHP version: 5.5.9-1
Re: Block Visibility in Drupal 6 based on CiviCRM gid
May 22, 2014, 09:28:06 am
I got it!  Thanks so much.  It was simpler than I thought. I had actually read that page, but somehow looked over this

Code: [Select]
<?php
$url 
= request_uri();
if (
strpos($url, "gid=16")) {
return 
TRUE;
}

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Block Visibility in Drupal 6 based on CiviCRM gid
May 22, 2014, 09:29:22 am
Precisely--very simple. Well done. :)
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Block Visibility in Drupal 6 based on CiviCRM gid

This forum was archived on 2017-11-26.