I am not a coder but I try to get around. I have a question. Maybe someone knows the answer.
I am trying to create a new html block in pages builder with this code
<a href="http://profile.mygamercard.net/<NickName>"> <img src="http://card.mygamercard.net/nxe/<NickName>.png" border=0> </a>
<NickName> should add the members nickname. At least that is my idea. How do I get that to work?
Or do I have to hire someone to make a mod?
|
It does not appear that dolphin processes any kind of string replacement when outputting the content of an html block.
But you can add your own processing.
Open inc\classes\BxDolPageView.php and edit the function that displays html blocks.
The function is getBlockCode_Echo at line 537.
Change the function from this....
function getBlockCode_Echo( $iBlockID, $sContent ) { return '<div class="dbContentHtml">' . $sContent . '</div>'; }
To This....
function getBlockCode_Echo( $iBlockID, $sContent ) { $sContent=str_replace("{MemberNickname}",getNickName((int)$_COOKIE['memberID']),$sContent); return '<div class="dbContentHtml">' . $sContent . '</div>'; }
Then save the file and upload.
Now just place {MemberNickname} anywhere in a custom html block and it will be replaced with the members nickname.
Note i use { instead of < as you did to make it look less like html code.
https://www.deanbassett.com |
It does not appear that dolphin processes any kind of string replacement when outputting the content of an html block.
But you can add your own processing.
Open inc\classes\BxDolPageView.php and edit the function that displays html blocks.
The function is getBlockCode_Echo at line 537.
Change the function from this....
function getBlockCode_Echo( $iBlockID, $sContent ) { return '<div class="dbContentHtml">' . $sContent . '</div>'; }
To This....
function getBlockCode_Echo( $iBlockID, $sContent ) { $sContent=str_replace("{MemberNickname}",getNickName((int)$_COOKIE['memberID']),$sContent); return '<div class="dbContentHtml">' . $sContent . '</div>'; }
Then save the file and upload.
Now just place {MemberNickname} anywhere in a custom html block and it will be replaced with the members nickname.
Note i use { instead of < as you did to make it look less like html code.
Thanks. This works but shows logged in users gamercard on every profile. You do not see the gamercard of other members when visiting their profile.I have to find a way for it to display the gamercard of the member only on their profile.
|
Oh. you did not specify that it was to be displayed only to the member when viewing their own profile.
That will be more complex, and you will be better off with a php block rather than a html block.
And of course PHP blocks can't simply be dragged into the page like the HTML blocks without a mod.
I'll have to poke around for ways to do what you need.
https://www.deanbassett.com |
This might be sutable.
Try this code for the the getBlockCode_Echo function.
function getBlockCode_Echo( $iBlockID, $sContent ) { if (isset( $this -> oProfileGen -> _iProfileID)) $memID = $this -> oProfileGen -> _iProfileID; elseif (isMember()) $memID = $_COOKIE['memberID'];
$sContent=str_replace("{MemberNickname}",getNickName($memID),$sContent); return '<div class="dbContentHtml">' . $sContent . '</div>'; }
I added 4 more lines of code so the nickname for the profile your viewing is used instead of the current logged in member.
https://www.deanbassett.com |
What you want is a "PHP Block". Check out this thread I posted a while back that brings up a similar issue and might have some useful info:
http://www.boonex.com/unity/forums/?action=goto&topic_id=Render-as-HTML
Jtado (sp?) had a nice summary of how to do this on his site, I think mrpowless did also. Busy now, but I will try to look up references later for you if no one else finds them.
Rob
|
Yes. I suggest a PHP block also.
What i offered was a quick solution for a HTML block.
The D6 code for adding a PHP block needs to be verified that it will work in D7 which i have not done yet.
You know, boonex should have already done this for D7. Yet we are still having to recode ourselves to put in a PHP block.
https://www.deanbassett.com |
@ deano92964: I really appreciate your effort with helping me out. I will try it and let you know
@ caltrade: I will have a look.
Regards,
Harvliet
|
This might be sutable.
Try this code for the the getBlockCode_Echo function.
function getBlockCode_Echo( $iBlockID, $sContent ) { if (isset( $this -> oProfileGen -> _iProfileID)) $memID = $this -> oProfileGen -> _iProfileID; elseif (isMember()) $memID = $_COOKIE['memberID'];
$sContent=str_replace("{MemberNickname}",getNickName($memID),$sContent); return '<div class="dbContentHtml">' . $sContent . '</div>'; }
I added 4 more lines of code so the nickname for the profile your viewing is used instead of the current logged in member.
Works great and I now see I really need a php block as I need to create a custom field like Gamertag because the code does not generate a gamercard for every username.
The code for gamercard generation works like this:
If a members gamertag would be for example 360 Playa, I would instruct the members to add a + to replace the space like 360+Playa
I would replace {MemberNickname} with my custom field {Gamertag}
Would this be possible with your html block hack or do I need to get the php block?
|
I would go with a php block. It would give you more control of what is done including looking up custom fields in the database.
https://www.deanbassett.com |
I would go with a php block. It would give you more control of what is done including looking up custom fields in the database.
Ok, thanks man
|