In this post I want to teach you how to create a PHP block on a page.
For example, you want to create a block displaying the membership level of the profile you're viewing.
1) First, you will have to create a simple HTML block. Navigate to '''Builders -> Pages Blocks''' and choose '''Profile''' from the '''Pages''' frop-down list. This is because we want to see this block on the profile page.
Drag the '''HTML Block''' from the '''Samples''' area to either of the columns in the '''Active Blocks''' area and place it under any block (for example under '''Photo Albums''' in the first column).
Now click the '''HTML Block''' you have just dragged. A small window will appear. In this window, you will have to create a language key for this block's '''Caption''' (for example '''_My Membership Type''' - notice that all language keys must have leading underscores).
Then make this block visible or invisible to '''Guests''' or '''Members''' by clicking or un-clicking the corresponding checkboxes.
And now enter any text in the field '''HTML-content'''. This text will not be used, so you can type anything here.
Press '''Save'''.
2) Now let's create the string for the key '''_My Membership Type'''. Navigate to '''Settings -> Language Settings''' and click the '''Add key''' button in the block '''Manage Keys'''.
In the window that will appear, enter the key name '''_My Membership Type''', choose its category, for example '''Boonex Profiler''' and type the corresponding strings for all installed languages, for example '''My Membership Type''' will be used for the English language. Now '''Save''' the window.
3) Ok. Now comes the most interesting part - you will have to turn this HTML block into a PHP block. This can be done in the database, so open phpMyAdmin (I assume once again that you know how to use it) and find the table '''sys_page_compose'''.
In this table you will have to search for the record corresponding to the block you have just created. Just search for its caption which will be '''_My Membership Type'''.
Now edit this record: change the value of the '''Func''' column into '''PHP''' instead of '''Echo'''. And enter your desired PHP code in the column '''Content'''. In our case this code will be:
echo GetMembershipStatus($this->oProfileGen->_iProfileID);
Now save the record (click '''Go''').
4) Now you will only have to recompile the block by moving it a little bit in '''Builders -> Pages Blocks -> Profile'''. And you should of course clean the cache: '''Admin Home -> Cache -> Clean All'''
5) Navigate to someone's profile and enjoy the result.
If i can find some download link for this "mod"
id be happy to plugin to my module manager:-)
In the time it took you to explain this, you could have added this functionality to page builder. This is not an acceptable method. Try again.
When I click on a members profile - it now shows the members level of membership - but it also shows other things like how long they have left at the current level - allowed actions - and in standard membership levels it provides a link to upgrade (which really should only show to the member himself...is there a way to just show the membership level without all of the other stuff?
The code for the file, inc/classes/BxDolPageViewAdmin.php has undergone several revisions since I posted it, so anyone wanting to make the changes should refer to Deano's instructions in the thread and NOT use the code posted in the ticket.
The point is... Deano offered this code four months ago, yet this ticket was placed on the D7.1 "Enhancements" pile.
Igor... if you want to do something that really helps, go clear that ticket.
I would like a small improvement
I would add next to the membership type, an icon that I downloaded.
example:
I created a membership type that is: moderator and this is what appears on the profile
Moderator
(View Allowed Actions)
expires: never
All information as well as "moderator" to me are not useful and I would like to add the icon (picture) that I downloaded specifically see more
And you should of course clean the cache: '''Admin Home -> Cache -> Clean All'''
Cannot see "Cache" option? in my dashboard? using 6.1.4 thanks
indeed, this should be fixed instead of setting instructions on the blog to tell those who have no clue what PHP/Mysql are, how to add a php block to their site.
Regards,
DosDawg
@Dosdawg - don't you remember busting my balls for saying exactly what you just said above?