It is currently 20 Feb 2018, 21:34

Anything Goesphpbb custom fields show custom links with text description (Showcase | Slideshow)

Anything, almost anything at all
(even advertisement if it's decent, spammers will be banned)
Post Reply
User avatar
tim

Administrator
View: Showcase | Slideshow
Topic Posts: 3/3
Posts: 2162
Joined: 26 Sep 2016, 00:16
Cash on hand: 7,946.37 GLP
Bank: 51,356.25 GLP
Gender: Guy
Location: Victoria, BC
Website: https://gimplearn.net
Operating System: Windows
GIMP Version: 2.8.22
My Personal Blog
My FineArtAmerica
x 1207
x 258
Contact:
Canada

phpbb custom fields show custom links with text description

Post#1 by tim » 15 Jun 2017, 21:31


This is for phpbb 3.2.0.
As Wallace (a user on this forum) suggested custom links that show different text link from literal url (since the url could be extra long and unfriendly to the eye).
I have hacked this phpbb 3.2.0 to do this. I thought I would share how since you might want the same for your forum.
What I did was added 6 Single Text field named linkonedisplay, linkoneurl, linktwodisplay, linktwourl, linkthreedisplay, linkthree url.
Then in viewtopy_body.html
instead of this code

Code: Select all

                <!-- BEGIN custom_fields -->
			<!-- IF not postrow.custom_fields.S_PROFILE_CONTACT -->
				<dd class="profile-custom-field profile-{postrow.custom_fields.PROFILE_FIELD_IDENT}"><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}{L_COLON}</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
			<!-- ENDIF -->
		<!-- END custom_fields -->
I replaced it with this code

Code: Select all

                <!-- DEFINE $LINK1DISPLAY = '' -->
		<!-- DEFINE $LINK2DISPLAY = '' -->
		<!-- DEFINE $LINK3DISPLAY = '' -->
		<!-- DEFINE $LINK1URL = '' -->
		<!-- DEFINE $LINK2URL = '' -->
		<!-- DEFINE $LINK3URL = '' -->
		<!-- BEGIN custom_fields -->
			<!-- DEFINE $SHOWIT = 'Y' -->
			<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME == 'linkonedisplay' --> <!-- IF postrow.custom_fields.PROFILE_FIELD_VALUE != '' -->
					<!-- DEFINE $LINK1DISPLAY = postrow.custom_fields.PROFILE_FIELD_VALUE_RAW -->
					<!-- DEFINE $SHOWIT = 'N' -->
			<!-- ENDIF --><!-- ENDIF -->
			<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME == 'linkoneurl' --> <!-- IF postrow.custom_fields.PROFILE_FIELD_VALUE != '' -->
					<!-- DEFINE $LINK1URL = postrow.custom_fields.PROFILE_FIELD_VALUE_RAW -->
					<!-- DEFINE $SHOWIT = 'N' -->
			<!-- ENDIF --><!-- ENDIF -->
			<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME == 'linktwodisplay' --> <!-- IF postrow.custom_fields.PROFILE_FIELD_VALUE != '' -->
					<!-- DEFINE $LINK2DISPLAY = postrow.custom_fields.PROFILE_FIELD_VALUE_RAW -->
					<!-- DEFINE $SHOWIT = 'N' -->
			<!-- ENDIF --><!-- ENDIF -->
			<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME == 'linktwourl' --> <!-- IF postrow.custom_fields.PROFILE_FIELD_VALUE != '' -->
					<!-- DEFINE $LINK2URL = postrow.custom_fields.PROFILE_FIELD_VALUE_RAW -->
					<!-- DEFINE $SHOWIT = 'N' -->
			<!-- ENDIF --><!-- ENDIF -->
			<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME == 'linkthreedisplay' --> <!-- IF postrow.custom_fields.PROFILE_FIELD_VALUE != '' -->
					<!-- DEFINE $LINK3DISPLAY = postrow.custom_fields.PROFILE_FIELD_VALUE_RAW -->
					<!-- DEFINE $SHOWIT = 'N' -->
			<!-- ENDIF --><!-- ENDIF -->
			<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME == 'linkthreeurl' --> <!-- IF postrow.custom_fields.PROFILE_FIELD_VALUE != '' -->
					<!-- DEFINE $LINK3URL = postrow.custom_fields.PROFILE_FIELD_VALUE_RAW -->
					<!-- DEFINE $SHOWIT = 'N' -->
			<!-- ENDIF --><!-- ENDIF -->
			<!-- IF not postrow.custom_fields.S_PROFILE_CONTACT and $SHOWIT == 'Y' -->
				<dd class="profile-custom-field profile-{postrow.custom_fields.PROFILE_FIELD_IDENT}"><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}{L_COLON}</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
			<!-- ENDIF -->
		<!-- END custom_fields -->
		<!-- Tin Tran my own hacked custom links with description -->
		<!-- IF $LINK1DISPLAY != '' and $LINK1URL != '' -->
			<dd class="profile-custom-field profile-{postrow.custom_fields.PROFILE_FIELD_IDENT}"><a href="{$LINK1URL}"><b>{$LINK1DISPLAY}</b></a></dd>
		<!-- ENDIF -->
		<!-- IF $LINK2DISPLAY != '' and $LINK2URL != '' -->
			<dd class="profile-custom-field profile-{postrow.custom_fields.PROFILE_FIELD_IDENT}"><a href="{$LINK2URL}"><b>{$LINK2DISPLAY}</b></a></dd>
		<!-- ENDIF -->
		<!-- IF $LINK3DISPLAY != '' and $LINK3URL != '' -->
			<dd class="profile-custom-field profile-{postrow.custom_fields.PROFILE_FIELD_IDENT}"><a href="{$LINK3URL}"><b>{$LINK3DISPLAY}</b></a></dd>
		<!-- ENDIF -->
What the code does is defaults some variables (the possible 3 links display text and urls) to empty strings.
Then as it loops through custom fields if it finds those values and it's not empty, it sets those variables to hold the RAW VALUES and not Show the custom field.
Then when it's done looping through custom fields, we do if checks on our variables; If they're not empty-strings, we output them as our links with custom text description and use the url as url so it doesn't display the urls.

You can see sample of it working under my Avatar on the left hand side (GIMP LEARN Forum on Reddit, My Blog, My FineArtAmerica).
0 x



aka Tin
Image gimplearn.net                                              

Registered members enjoy ads-free content
User avatar
tim

Administrator
View: Showcase | Slideshow
Topic Posts: 3/3
Posts: 2162
Joined: 26 Sep 2016, 00:16
Cash on hand: 7,946.37 GLP
Bank: 51,356.25 GLP
Gender: Guy
Location: Victoria, BC
Website: https://gimplearn.net
Operating System: Windows
GIMP Version: 2.8.22
My Personal Blog
My FineArtAmerica
x 1207
x 258
Contact:
Canada

Post#2 by tim » 15 Jun 2017, 21:34


I only hacked it for viewtopic_body.html... I guess if you really wanted you could do it for other pages as well..but I thought other pages are not viewed very often..and even if they show as regular custom fields people still know what those fields are for since i added them in properly order. display first then url follows for the 3 links so 6 fields... But for now I am happy with the hack for when users are viewing topics.
0 x



aka Tin
Image gimplearn.net                                              

User avatar
tim

Administrator
View: Showcase | Slideshow
Topic Posts: 3/3
Posts: 2162
Joined: 26 Sep 2016, 00:16
Cash on hand: 7,946.37 GLP
Bank: 51,356.25 GLP
Gender: Guy
Location: Victoria, BC
Website: https://gimplearn.net
Operating System: Windows
GIMP Version: 2.8.22
My Personal Blog
My FineArtAmerica
x 1207
x 258
Contact:
Canada

Post#3 by tim » 15 Jun 2017, 23:03


I made a change to make it tighter validation.
Made all the displays custom fields (linkonedisplay,linktwodisplay,linkthreedisplay) Single Text Field (Alphanumerics with spacers).
Made all the url custom fields (linkoneurl,linktwourl,linkthreeurl) URLs so there's more validation.
Okay i am happy with the change now.
0 x



aka Tin
Image gimplearn.net                                              

Post Reply

Last 20 Members Who Visited This Topic

User avatar Graechan (2), User avatar gnerd (1)

  • Similar Topics
    Replies
    Views
    Last post
• Featuring Members' Works (Image Attachments Only) •
1: Ella
2: tim
3: oldmangrumpy
4: Ella
5: leopardo-40
6: RJKD
7: Issabella

Who is online

Users browsing this forum: No registered users and 2 guests