HTML (on profile field)

Blocks ::: block_profilespecifichtml
Maintained by Valery Fremaux
This simple bloc allows outputing HTML content in a bloc with several versions based onthe check of custom profile fields values (2 checks)
Latest release:
35 sites
10 downloads
6 fans
Current versions available: 12

This bloc is a clone of the standard HTML block but provides custom profile field control over the version of content which is displayed.

Up to 2 fields can be checked and combined with logical (AND, OR, XOR) operators.

The Moodle 2.x versions are the result of the French state level project "ENTLibre 2.0" Of the National Funding program "Investissement d'Avenir"

Contributors

Valery Fremaux (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Comments

  • Michael Milette
    Sat, 27 June 2015, 3:42 AM
    Hi Valery, the link to "More documentation on this plugin" results in a 404 error.

    Can you give me a sample scenario of when I might want to use this plugin?

    Best regards,

    Michael
  • Chris Chapman
    Thu, 5 Nov 2015, 6:35 PM
    Hi Michael - a scenerio for our institution is to show relevant and personalized news/content for staff (and students) in a particular department. Havn't installed yet, running 2.9 so will see how it works and maybe make a few mods.
  • Nicholas Stefanski
    Thu, 21 Apr 2016, 6:35 AM
    Hi, I love the concept, but unfortunately I am having trouble with it on 2.7

    We have a custom profile field "Campus", since all of our campuses aare serviced by a single LMS. I had an embedded slideshow for each campus, and wanted users to only see theirs, so I made a block for each campus and used the rule "Campus = [campus name]". No content for all users, just content for matching users. The first two campuses worked perfectly, but the third group was able to see all three slideshows. I tried various other ways of doing the rule, including using the "Like" operator, but every rule either let the third campus see all of the slideshows or no slideshow at all.

    The only thing that I can think of is that while the first two campuses are a single word, "Austin" and "Boulder", the third campus is two words with a special character: "Boulder - Online". Since this profile field is a multi-select, If tried making a new selection "Boulder Online", but when I set a user to have that as their campus, the slideshow was not visible at all. So I don't know if there's a second issue going on with caching the profile field setting or something?

    Anyone have any thoughts on this, please let me know!
  • Valery Fremaux
    Thu, 21 Apr 2016, 8:36 PM
    Hi Nicolas

    Actually i do not tried what happens in table mdl_user_profile_data when a field is multiselect. The profile field resolution uses an internal eval() statement to build the comparison expression. I would not believe (before testing) that a hyphen would break the = or event Regular expression matching. I will have some tests ASAP on the use case.
  • Nicholas Stefanski
    Sat, 23 Apr 2016, 12:52 AM
    Valery,

    I did some additional testing. I switched to using the "Institution" field to avoid any possible problems with using a multi-select profile field, or a custom field in general. Here are the inputs and what I saw:

    institution result
    Austin User sees only correct blocks
    Boulder User sees only correct blocks
    Boulder - Online User sees all blocks
    Boulder Online User sees no blocks
    BoulderOnline User sees only correct blocks
    Online User sees only correct blocks
    Isla Nublar User sees no blocks

    So it looks to me like the hyphens are indeed breaking something, and causing users to see all blocks using that user field. If there is a space, but no hyphen, then the opposite happens, and the user does not even see the blocks that they should based on the field rules. I am using this on Moodle 2.7, so I don't know if there was a change in core code from 2.6 that would've caused this?

    I'm going to just switch to using Institution names without spaces and special characters (thank goodness for bulk user actions and CSV uploads!), but I thought I'd share my findings in case you want to update the block for the newer Moodle releases.
  • shivshankar kesha
    Mon, 9 Apr 2018, 2:15 PM
    Hi Valery,

    Thanks for sharing such nice block.
    Is it possible to hide block to unmatched users using this block.
  • shivshankar kesha
    Mon, 9 Apr 2018, 2:40 PM
    hi Valery,

    got solutions, if we don't write message for unmatched users then its not appearing . Thanks once again.
  • ciaran oco
    Wed, 24 Oct 2018, 7:37 PM
    hi Valery,

    I can't seem to get this to work on Moodle33.

    No matter if I use a custom field or any standard field I get this error "Exception - syntax error, unexpected '==' (T_IS_EQUAL) ". The fiekd name does not have a - in it. Any ideas please? It will be a great solution if I can get this working.

    many thanks\merci

    Ciarán
  • ciaran oco
    Tue, 30 Oct 2018, 8:46 PM
    Hi again, we applied the latest githib version rather than the last downloadable plugin version as it was more up to date and the error disappeared. Unfortunately none of the custom or standard profile fields seem to pick up on the conditional formula i.e. no users match even though they have the field values. Oh well.
  • Jerry S
    Thu, 12 Dec 2019, 8:08 AM
    Hi Ciaran,

    If you still having issues with "Exception - syntax error, unexpected '==' (T_IS_EQUAL) " then alter the code in block_profilespecifichtml.php line 109. You need to add if(!empty($uservalue)){

    if ($this->config->op1 == '~=') {
    $expr = "\$res1 = preg_match('/{$this->config->value1}/', '{$uservalue}'}) ;";
    } else {
    if(!empty($uservalue)){
    $expr = "\$res1 = {$uservalue} {$this->config->op1} '{$this->config->value1}' ;";
    }

  • Plínio Felipe Peçanha Oliveira
    Tue, 8 Feb 2022, 5:40 PM
    Please update this plugin 3.10 3.11 4.0
    Thx
Please login to post comments