HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Help needed generating links from a "Custom Profile Field"

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#100164 (In Topic #19658)
TQ
Avatar

Honoured member

Links to supplementary information from a users profile

Hi All,

My users are mainly licensed Radio Amateurs (RA's) that have relevant pages at a number of RA related sites around the globe.

I have a "Callsign" Custom Profile Field which stores the users callsign as not all my members are RA's.

I would like to add something to the users profile information (which is currently only visible to other verified RA's) that resembles the following:

You may also view my details at the following locations :

QRZ QRZ - QRZCQ QRZCQ - APRS.fi APRS.fi - HamCall HamCall - HRDLog HRDLog

You'll note in the code LZ2NJG (the callsign) is hard coded but I would like to pick this up from the users profile ...

Code

<p>You may also view my details at the following locations :</p>
<p><a href="http://www.qrz.com/db/LZ2NJG" target="_blank"> <img src="http://www.qrz.com/favicon.ico" alt="QRZ" width="16" height="16" longdesc="http://qrz.com/db/lz2njg" /> QRZ</a> - <img src="http://qrzcq.com/favicon.ico" alt="QRZCQ" width="16" height="16" longdesc="http://qrzcq.com/call/LZ2NJG" /><a href="http://qrzcq.com/call/LZ2NJG" target="_blank"> QRZCQ </a> - <img src="http://aprs.fi/favicon.ico" alt="APRS.fi" width="16" height="16" longdesc="http://aprs.fi/info/?call=lz2njg*" /><a href="http://aprs.fi/info/?call=lz2njg*" target="_blank"> APRS.fi </a> - <img src="http://hamcall.net/favicon.ico" alt="HamCall" width="16" height="16" longdesc="http://hamcall.net/call/LZ2NJG" /> <a href="http://hamcall.net/call/LZ2NJG" target="_blank">HamCall</a> - <img src="http://www.hrdlog.net/images/favicon.ico" alt="HRDLog" width="16" height="16" longdesc="http://www.hrdlog.net/ViewLogbook.aspx?user=LZ2NJG" /> <a href="http://www.hrdlog.net/ViewLogbook.aspx?user=LZ2NJG" target="_blank">HRDLog</a></p>

... and I would like none of this information to be displayed if the user has not added anything to the callsign field.

That's the basics and I'd settle for that but then there's the mission creep. Not all RA's are listed on all of the sites, I need a way of allowing the member to confirm that they have a listing on these sites either by the member ticking a box or the code testing the link to make sure it's valid.

I would also like this info to be in a prominent position within the profile or even on a separate tab.

I am aware that I could use custom fields and ask the user to type in the full URL to the relevant pages but I suspect, at least to start with, they won't bother. I did try to add such a field with a default value but I couldn't work out how to embed the callsign into it and in any event, unless the user typed something into the field, it wasn't displayed.

I am not expecting anyone to do the work for me (I remain in Jasons debt for creating the download email add-on) but I would appreciate as bigger push as I can get to get me started.

Thanks for reading this and yet another gratuitous 'Well Done' to the ocPortal team for a great product.

Nick
 


Last edit: by TQ
Back to the top
 
Posted
Rating:
#100171
Avatar

Community saint

The code technique will differ slightly depending on exactly where on the page you want the information to appear because of when the information becomes available.

The example I'll give will be for putting the callsign links in the Details section of OCF_MEMBER_PROFILE_ABOUT.tpl because that is the closest to what I have done similarly on the OCF_MEMBER_PROFILE_SCREEN in v7.

Replace the following code which loops through the custom profile fields.

Code

{+START,LOOP,EXTRA_INFO_DETAILS}
   <tr>
      <th class="de_th">{_loop_key*}:</th>
      <td><span>{_loop_var*}</span></td>
   </tr>
{+END}
With:

Code

{+START,LOOP,EXTRA_INFO_DETAILS}
   {+START,IF,{$NEQ,{_loop_key*},Callsign}}
      <tr>
         <th class="de_th">{_loop_key*}:</th>
         <td><span>{_loop_var*}</span></td>
      </tr>
   {+END}

   {+START,IF,{$EQ,{_loop_key*},Callsign}}
      {+START,IF_NON_EMPTY,{_loop_var*}}
         <th class="de_th">{_loop_key*}:</th>
         <td>
<p>You may also view my details at the following locations :</p>
<p><a href="http://www.qrz.com/db/{_loop_var*}" target="_blank"> <img src="http://www.qrz.com/favicon.ico" alt="QRZ" width="16" height="16" longdesc="http://qrz.com/db/{_loop_var*}" /> QRZ</a> - <img src="http://qrzcq.com/favicon.ico" alt="QRZCQ" width="16" height="16" longdesc="http://qrzcq.com/call/{_loop_var*}" /><a href="http://qrzcq.com/call/{_loop_var*}" target="_blank"> QRZCQ </a> - <img src="http://aprs.fi/favicon.ico" alt="APRS.fi" width="16" height="16" longdesc="http://aprs.fi/info/?call={_loop_var*}*" /><a href="http://aprs.fi/info/?call={_loop_var*}*" target="_blank"> APRS.fi </a> - <img src="http://hamcall.net/favicon.ico" alt="HamCall" width="16" height="16" longdesc="http://hamcall.net/call/{_loop_var*}" /> <a href="http://hamcall.net/call/{_loop_var*}" target="_blank">HamCall</a> - <img src="http://www.hrdlog.net/images/favicon.ico" alt="HRDLog" width="16" height="16" longdesc="http://www.hrdlog.net/ViewLogbook.aspx?user={_loop_var*}" /> <a href="http://www.hrdlog.net/ViewLogbook.aspx?user={_loop_var*}" target="_blank">HRDLog</a></p>
         </td>
      {+END}
   {+END}
{+END}
The first part just tells the systems to  display any field not named Callsign as normal.

The second part will display the links if its a Callsign field, but only if a call sign is supplied.

It will display the links from all the locations and will not check if the links are valid.

If you wanted to only display links from sites where they have accounts then is probably best to have a custom profile field checkbox for each site. You can then test the checkbox and only display the valid links.

If you want to display the links elsewhere on the page then you would probably have to use the {$CPF_VALUE,Some Custom Field} method instead of the looping method above.

Note that I haven't tested the code.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#100185
TQ
Avatar

Honoured member

Hi Temp1024,

Many thanks for taking the time to reply. I'll look into your suggestions tonight and keep you posted.

Much appreciated, Nick
Back to the top
 
Posted
Rating:
#100212
TQ
Avatar

Honoured member

Hi Temp1024,

I'm confused (no surprise there).

I made the changes as suggested and there was no difference to the displayed information. I flushed the template cache and emptied my browser cache and still no difference.

I commented out the entire, original, START,LOOP,EXTRA_INFO_DETAILS and I was still presented with the custom fields on the profile tab.

Am I looking in the wrong place for the result (profile tab) or are the custom fields being displayed from a different template (or different part)? I know if I damage the code (I left out a END when I was tinkering) I caused a stack trace error so I must be close.

Any thoughts?

Nick
Back to the top
 
Posted
Rating:
#100215
Avatar

Community saint

Woooops!!!, its actually my fault :$ TQ not yours.

I identified the wrong loop. Looks like the correct loop to work on should be:

Code

{+START,LOOP,CUSTOM_FIELDS}
   {$SET,is_messenger_field,{$EQ,{NAME},{!DEFAULT_CPF_im_msn_NAME},{!DEFAULT_CPF_im_aim_NAME},{!DEFAULT_CPF_im_yahoo_NAME},{!DEFAULT_CPF_im_skype_NAME},{!DEFAULT_CPF_im_icq_NAME},{!DEFAULT_CPF_im_jabber_NAME},{!DEFAULT_CPF_sn_twitter_NAME},{!DEFAULT_CPF_sn_facebook_NAME},{!DEFAULT_CPF_sn_google_NAME}}}

   {+START,IF,{$NOT,{$GET,is_messenger_field}}}
      <tr>
         <th class="de_th">
            {NAME*}:
         </th>

         <td>
            <span{+START,IF,{$EQ,{NAME},{!SPECIAL_CPF__ocp_fullname}}} class="fn given-name"{+END}>
               {+START,IF_EMPTY,{ENCRYPTED_VALUE}}
                  {VALUE}
               {+END}
               {+START,IF_NON_EMPTY,{ENCRYPTED_VALUE}}
                  {+START,IF,{$JS_ON}}{!DATA_ENCRYPTED} <a href="javascript:decrypt_data('{ENCRYPTED_VALUE;^*}');" title="{!DECRYPT_DATA}: {!DESCRIPTION_DECRYPT_DATA=}">{!DECRYPT_DATA}</a>{+END}
                  {+START,IF,{$NOT,{$JS_ON}}}{ENCRYPTED_VALUE*}{+END}
               {+END}
            </span>
         </td>
      </tr>
   {+END}
{+END}
Can you confirm that I've identified the correct one this time by changing:

Code

{NAME*}:
to say:

Code

{NAME*}: TEST
and see if the word TEST is added to the custom profile field names.

If it is then I can supply you with new replacement code.

Sorry about that TQ.


Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#100216
TQ
Avatar

Honoured member

Yip, the

Code

{NAME*}: TEST

test worked!

Thanks again

Nick
Back to the top
 
Posted
Rating:
#100220
Avatar

Community saint

OK, Replace:

Code

  {+START,IF,{$NOT,{$GET,is_messenger_field}}}
      <tr>
         <th class="de_th">
            {NAME*}:
         </th>

         <td>
            <span{+START,IF,{$EQ,{NAME},{!SPECIAL_CPF__ocp_fullname}}} class="fn given-name"{+END}>
               {+START,IF_EMPTY,{ENCRYPTED_VALUE}}
                  {VALUE}
               {+END}
               {+START,IF_NON_EMPTY,{ENCRYPTED_VALUE}}
                  {+START,IF,{$JS_ON}}{!DATA_ENCRYPTED} <a href="javascript:decrypt_data('{ENCRYPTED_VALUE;^*}');" title="{!DECRYPT_DATA}: {!DESCRIPTION_DECRYPT_DATA=}">{!DECRYPT_DATA}</a>{+END}
                  {+START,IF,{$NOT,{$JS_ON}}}{ENCRYPTED_VALUE*}{+END}
               {+END}
            </span>
         </td>
      </tr>
   {+END}
with:

Code

  {+START,IF,{$NEQ,{NAME},Callsign}}
   {+START,IF,{$NOT,{$GET,is_messenger_field}}}
      <tr>
         <th class="de_th">
            {NAME*}:
         </th>

         <td>
            <span{+START,IF,{$EQ,{NAME},{!SPECIAL_CPF__ocp_fullname}}} class="fn given-name"{+END}>
               {+START,IF_EMPTY,{ENCRYPTED_VALUE}}
                  {VALUE}
               {+END}
               {+START,IF_NON_EMPTY,{ENCRYPTED_VALUE}}
                  {+START,IF,{$JS_ON}}{!DATA_ENCRYPTED} <a href="javascript:decrypt_data('{ENCRYPTED_VALUE;^*}');" title="{!DECRYPT_DATA}: {!DESCRIPTION_DECRYPT_DATA=}">{!DECRYPT_DATA}</a>{+END}
                  {+START,IF,{$NOT,{$JS_ON}}}{ENCRYPTED_VALUE*}{+END}
               {+END}
            </span>
         </td>
      </tr>
   {+END}
   {+END}
   {+START,IF,{$EQ,{NAME},Callsign}}
      {+START,IF_NON_EMPTY,{VALUE}}
      <tr>
         <th class="de_th">
            {NAME*}:
         </th>
         <td>
<p>You may also view my details at the following locations :</p>
<p><a href="http://www.qrz.com/db/{VALUE}" target="_blank"> <img src="http://www.qrz.com/favicon.ico" alt="QRZ" width="16" height="16" longdesc="http://qrz.com/db/{VALUE}" /> QRZ</a> - <img src="http://qrzcq.com/favicon.ico" alt="QRZCQ" width="16" height="16" longdesc="http://qrzcq.com/call/{VALUE}" /><a href="http://qrzcq.com/call/{VALUE}" target="_blank"> QRZCQ </a> - <img src="http://aprs.fi/favicon.ico" alt="APRS.fi" width="16" height="16" longdesc="http://aprs.fi/info/?call={VALUE}*" /><a href="http://aprs.fi/info/?call={VALUE}*" target="_blank"> APRS.fi </a> - <img src="http://hamcall.net/favicon.ico" alt="HamCall" width="16" height="16" longdesc="http://hamcall.net/call/{VALUE}" /> <a href="http://hamcall.net/call/{VALUE}" target="_blank">HamCall</a> - <img src="http://www.hrdlog.net/images/favicon.ico" alt="HRDLog" width="16" height="16" longdesc="http://www.hrdlog.net/ViewLogbook.aspx?user={VALUE}" /> <a href="http://www.hrdlog.net/ViewLogbook.aspx?user={VALUE}" target="_blank">HRDLog</a></p>
         </td>
      </tr>
      {+END}
   {+END}

That should do it, assuming I haven't made any silly copy/replace stuff-ups.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#100229
TQ
Avatar

Honoured member

Hi Temp1024,

Thank you so much for the time you spent on this, it worked almost perfectly from the get-go.

I had a few minor problems, the table setup wasn't quite right and the callsign itself was missing from the screen completely. I guess this is what you meant about copy n paste.

From your foundation I've fixed these problems but would appreciate it if you would look over my revision in case I've gone overboard due to lack of knowledge and understanding.

Code

{+START,IF,{$NEQ,{NAME},Callsign}}
   {+START,IF,{$NOT,{$GET,is_messenger_field}}}
      <tr>
         <th class="de_th">
            {NAME*}:
         </th>

         <td>
            <span{+START,IF,{$EQ,{NAME},{!SPECIAL_CPF__ocp_fullname}}} class="fn given-name"{+END}>
               {+START,IF_EMPTY,{ENCRYPTED_VALUE}}
                  {VALUE}
               {+END}
               {+START,IF_NON_EMPTY,{ENCRYPTED_VALUE}}
                  {+START,IF,{$JS_ON}}{!DATA_ENCRYPTED} <a href="javascript;decrypt_data('{ENCRYPTED_VALUE;^*}');" title="{!DECRYPT_DATA}: {!DESCRIPTION_DECRYPT_DATA=}">{!DECRYPT_DATA}</a>{+END}
                  {+START,IF,{$NOT,{$JS_ON}}}{ENCRYPTED_VALUE*}{+END}
               {+END}
            </span>
         </td>
      </tr>
   {+END}
   {+END}
   {+START,IF,{$EQ,{NAME},Callsign}}
      {+START,IF_NON_EMPTY,{VALUE}}
      <tr>
         <th class="de_th">
            {NAME*}:
         </th>
 
  <td>        
<font style="text-transform: uppercase;">
<span{+START,IF,{$EQ,{NAME},{!SPECIAL_CPF__ocp_fullname}}} class="fn given-name"{+END}>
               {+START,IF_EMPTY,{ENCRYPTED_VALUE}}
                  {VALUE}
               {+END}
 {+START,IF_NON_EMPTY,{ENCRYPTED_VALUE}}
                  {+START,IF,{$JS_ON}}{!DATA_ENCRYPTED} <a href="javascript;decrypt_data('{ENCRYPTED_VALUE;^*}');" title="{!DECRYPT_DATA}: {!DESCRIPTION_DECRYPT_DATA=}">{!DECRYPT_DATA}</a>{+END}
                  {+START,IF,{$NOT,{$JS_ON}}}{ENCRYPTED_VALUE*}{+END}
               {+END}            
            </font> </tr></td>
             <tr>
             <th class="de_th">
                 View my details at:
            </th>
<td><a href="http://www.qrz.com/db/{VALUE}" target="_blank"> QRZ</a> <a href="http://qrzcq.com/call/{VALUE}" target="_blank"> QRZCQ </a><a href="http://aprs.fi/info/?call={VALUE}*" target="_blank"> APRS.fi </a> <a href="http://hamcall.net/call/{VALUE}" target="_blank">HamCall</a>  <a href="http://www.hrdlog.net/ViewLogbook.aspx?user={VALUE}" target="_blank">HRDLog</a></p>
         </td>
      </tr>
      {+END}
   {+END}


I took on-board your idea regarding check boxes:
If you wanted to only display links from sites where they have accounts then is probably best to have a custom profile field checkbox for each site. You can then test the checkbox and only display the valid links.


I have created Yes/No type Custom Fields called QRZ_Listed & HAMCall_Listed to question the member if they are listed on these sites.

If it's not too much of a liberty to ask, could you point me in the direction of how I can loop through these answers and only display the appropriate link from the existing code. Please keep in mind, I do very much want to learn so do as little as is necessary to help me grasp the principals.

Thank you again for your valuable time.

Nick
Back to the top
 
Posted
Rating:
#100235
Avatar

Community saint

TQ said

the table setup wasn't quite right
I'm surprise about that, didn't think I messed that up. O_o

TQ said

the callsign itself was missing from the screen completely.
That will be because I just wrapped my code around the code you had in your original post.

TQ said

would appreciate it if you would look over my revision in case I've gone overboard due to lack of knowledge and understanding.
Because the code is not formatted its difficult to read, but what I did notice was that you you are missing the </span> tag and are not closing tags in the correct order. i.e your order is:

Code

<tr>
 <td>
   <font>
    <span>
    </font>
   </tr>
  </td>
Instead of:

Code

<tr>
 <td>
   <font>
    <span>
    </span>
   </font>
 </td>
</tr>
If the code was formatted you would have been able to spot the problem yourself easily.

TQ said

If it's not too much of a liberty to ask, could you point me in the direction of how I can loop through these answers and only display the appropriate link from the existing code.
Happy to.

TQ said

Please keep in mind, I do very much want to learn so do as little as is necessary to help me grasp the principals.
Works for me :thumbs:

Based on the techniques covered so far the simplest thing to do would be to add another loop. That loop should test for QRZ_Listed & HAMCall_Listed fields and only display those fields.

The main thing to be aware of is that because you will end up with nested loops, you will have to save {VALUE} into a temporary variable using $SET in the first loop (the one you already have), and retrieve it via $GET in the new loop.

I hope that makes sense.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#100286
TQ
Avatar

Honoured member

Hi Temp1024,

Thanks for the peruse of my revision, you're right, if my code wasn't so messy I would have spotted it. (Will try harder!)

I spent the day trying all sorts of things and, to be honest, have got nowhere albeit I've learnt a lot more about OCP.
I've tried:

Code

{+START,IF,$EQ,{QRZCQ_LISTED},xxx}}} etc

Where xxx is YES,Y,1,2. This produced nothing.
... and I still don't know for sure what a Yes/No field returns! I think it's YES but I still have other problems so I tried

Code

{+START,IF,$NEQ,{QRZCQ_LISTED},xxx}}} etc

This produced everything (when it shouldn't), but still with other errors. This suggests to me that QRZCQ_LISTED is empty but I have no idea how to categorically prove it because I don't trust the code I put around it.

I was mindful of your comment:

Temp1024 said

The main thing to be aware of is that because you will end up with nested loops, you will have to save {VALUE} into a temporary variable using $SET in the first loop (the one you already have), and retrieve it via $GET in the new loop.

and looking through the templates code I was inspired to try this:

Code

<!-- Start of my changes -->
{$SET,is_listed_field,{$EQ,{NAME},{QRZ_LISTED},{!DEFAULT_CPF_QRZCQ_LISTED},{!DEFAULT_CPF_APRS_LISTED},{!DEFAULT_CPF_HAMCALL_LISTED},{!DEFAULT_CPF_HAMLOG_LISTED}}}
{+START,IF,{$GET,is_listed_field}}
                    {+START,SET,listed_fields}
                        {$GET,listed_fields}
                        <td>
                        {+START,IF,{$EQ,{NAME},{QRZ_LISTED}}}<li><a href="http://www.qrz.com/db/{VALUE}" target="_blank"> QRZ</a></li>{+END}
                        <!-- Give this error: A parameter, QRZ_LISTED, is referenced in the template, OCF_MEMBER_PROFILE_ABOUT, but not passed -->
                        {+START,IF,{$EQ,{NAME},{!DEFAULT_CPF_QRZCQ_LISTED}}}<li><a href="http://qrzcq.com/call/{VALUE}" target="_blank"> QRZCQ </a></li>{+END}
                        {+START,IF,{$EQ,{NAME},{!DEFAULT_CPF_APRS_LISTED}}}<li><a href="http://aprs.fi/info/?call={VALUE}*" target="_blank"> APRS.fi </a></li>{+END}
                        {+START,IF,{$EQ,{NAME},{!DEFAULT_CPF_HAMCALL_LISTED}}}<li><a href="http://hamcall.net/call/{VALUE}" target="_blank"> HamCall</a>{+END}
                        {+START,IF,{$EQ,{NAME},{!DEFAULT_CPF_HAMLOG_LISTED}}}<li><a href="http://www.hrdlog.net/ViewLogbook.aspx?user={VALUE}" target="_blank"> HRDLog</a>{+END}
                        <!-- Last 4 lines give this error: A language entry is missing: DEFAULT_CPF_xxxx_LISTED (where xxxx is QRZCQ,APRS,HAMCALL,HAMLOG) -->
                        </td>
                    {+END}
                {+END}
<!-- End of my changes -->

You'll see from my comments in the code that there are similar and persistent errors. I've also tried a bunch of other things but they didn't hold water either.

Much of my problem is that I'm struggling to find what I want in the OCP help, not because its not there, but I don't seem to be able to easily find it. It took me hours to find this page and I still haven't found any good examples with comments to build from.

So, sorry to say, I need more help than I hoped. Could you give me a little more to go on or at least tell me where I'm going so desperately wrong.

Thanks as always

Nick


Back to the top
 
Posted
Rating:
#100295
Avatar

Community saint

TQ said

have got nowhere albeit I've learnt a lot more about OCP.
As long as you are learning things then thats good. Its not always easy.

TQ said

I've tried:

Code

{+START,IF,$EQ,{QRZCQ_LISTED},xxx}}} etc
Its the little details that will get you. Compare your code to what we did with Callsign:

Code

{+START,IF,{$EQ,{NAME},Callsign}}
We are comparing a parameter{NAME} against a value of Callsign. So if QRZCQ_LISTED is the name of a custom profile field like Callsign is, then what you want is:

Code

{+START,IF,{$EQ,{NAME},QRZCQ_LISTED}}
That gives you the name check. For the value check is similar.

Code

{+START,IF,{$EQ,{VALUE},Yes}}
So you end up with:

Code

{+START,IF,{$EQ,{NAME},QRZCQ_LISTED}}
   {+START,IF,{$EQ,{VALUE},Yes}}
   ...
   {+END}
{+END}

TQ said

I still don't know for sure what a Yes/No field returns! I think it's YES
Well, what gets displayed on screen is Yes, so that must be the answer.

TQ said

but I still have other problems so I tried

Code

{+START,IF,$NEQ,{QRZCQ_LISTED},xxx}}} etc

This produced everything (when it shouldn't) ... This suggests to me that QRZCQ_LISTED is empty
Actually in all likelihood it should be producing everything because I suspect that the field name is not actually QRZCQ_LISTED but more likely you called it QRZCQ_Listed or QRZ_Listed .

TQ said

but I have no idea how to categorically prove it because I don't trust the code I put around it.
When in doubt, print it out. Just put:

Code

NAME='{NAME}', VALUE='{VALUE}'
In the loop and it will confirm what each name is and what value it contains.

Just keep things simple and do it one step at a time.

As for the errors:
A parameter, QRZ_LISTED, is referenced in the template, OCF_MEMBER_PROFILE_ABOUT, but not passed –>
QRZ_LISTED is not a parameter, its a custom profile field name, so it sout not be referenced as {QRZ_LISTED}.

And:
A language entry is missing: DEFAULT_CPF_xxxx_LISTED
occurs  because you have not created any language strings, and nor should you have. That code has no relevance to what you are trying to achieve.

You need to know how to read the different constructs. From the documentation:
Tempcode provides four constructs other than the plain text of the template itself:

    Parameters: {PARAMETER} where PARAMETER is a code-name of something that was actually passed to the template

    Language strings: {!STRING,<parameters>…} where STRING is a real language string from a loaded language file (e.g. Banner code could use strings from banners.ini, but most other code could not; global.ini contains strings usable anywhere)

    Symbols: {$SYMBOL,<parameters>…} where SYMBOL is a real symbol ocPortal supports. Embedding a symbol is like making a function call or running a command in the complex place, or a substitution in the simple case

    Directives: {+START,DIRECTIVE,<parameters>…}…{+END,DIRECTIVE} where DIRECTIVE is a real directive ocPortal supports. Directives essentially wrap portions of the template, controlling that portion; they are generally used for types of condition checking (e.g. IF) or loop. There are also directives like {+IMPLODE,<parameters>…} that do not wrap, but work outside the normal "string manipulation" bounds that symbols do

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#100296
TQ
Avatar

Honoured member

Hi Temp1024,

Thank you for the very detailed and useful answer, much appreciated. I'll go back over it and comment on any other areas of discussion later but for now...

I tried your suggestion as follows (QRZ_Listing is correct in both characters and case):

Code

                        {+START,IF,{$EQ,{NAME},QRZ_Listing}}
                            NAME='{NAME}
                            {+START,IF,{$EQ,{VALUE},YES}}
                            NAME='{NAME}', VALUE='{VALUE}'
                            <p><a href="http://www.qrz.com/db/{VALUE}" target="_blank"> QRZ</a><br>{+END}
                        {+END}


... and got nothing.

I looked at the database on the server and discovered that hamfiles.ocp_f_custom_fields field_type is "Tick". From hamfiles.ocp_f_member_custom_fields I learnt that N/A = Blank, No = 0 and YES = 1.

So I changed the code to this:

Code

                        {+START,IF,{$EQ,{NAME},QRZ_Listing}}
                            NAME='{NAME}', VALUE='{VALUE}'
                            {+START,IF,{$EQ,{VALUE},1}}
                            NAME='{NAME}', VALUE='{VALUE}'
                            <p><a href="http://www.qrz.com/db/{VALUE}" target="_blank"> QRZ</a><br>{+END}
                        {+END}


The table cell still shows absolutly nothing so I printed the Name and Value before the first loop:

Code

                        NAME='{NAME}', VALUE='{VALUE}'
                        {+START,IF,{$EQ,{NAME},QRZ_Listing}}
                            NAME='{NAME}', VALUE='{VALUE}'
                            {+START,IF,{$EQ,{VALUE},1}}
                            NAME='{NAME}', VALUE='{VALUE}'
                            <p><a href="http://www.qrz.com/db/{VALUE}" target="_blank"> QRZ</a><br>{+END}
                        {+END}


Now the table cell reads: NAME='Callsign', VALUE='LZ2NJG' (from the line preceding the new loops). From this I assume it's not accessing QRZ_Listing in the database but the loop is empting the values in Name and Value.

What am I missing?

Nick

Nick
Back to the top
 
Posted
Rating:
#100297
Avatar

Community saint

What that is telling me is two things,

1) Even though it is a Yes/No type field it actually has 3 states - Yes/No/Blank, and the Blank states are filtered out even before they get to the template.

2) In the profile you are looking at, you have not explicitly chosen Yes or No for QRZ_Listing or any of the other Yes/No fields, so you will not see anything until you edit the profile and change them to Yes' or No's.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#100298
TQ
Avatar

Honoured member

temp1024 said


2) In the profile you are looking at, you have not explicitly chosen Yes or No for QRZ_Listing or any of the other Yes/No fields, so you will not see anything until you edit the profile and change them to Yes' or No's.

Not so, the profile LZ2NJG (Me) has yes for 2 fields, no for one and blank for the other 2.

Nick
Back to the top
 
Posted
Rating:
#100299
Avatar

Community saint

TQ said

Not so, the profile LZ2NJG (Me) has yes for 2 fields, no for one and blank for the other 2.
Ah yes, I see whats happening now. Its time to the second loop.

Because everything is now happening within:

Code

{+START,IF,{$NEQ,{NAME},Callsign}}
{NAME} will never change, so you need to start another loop:

Code

{+START,LOOP,CUSTOM_FIELDS}
just before

Code

{+START,IF,{$EQ,{NAME},QRZ_Listing}}






Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#100310
TQ
Avatar

Honoured member

That sorted it, thank you!

I had to go back to something you mentioned in one of your previous posts SET & GET to replace VALUE in the URL as it now contained YES not the Callsign. That's now done so it's all working.

Before I finish with this subject I thought I'd better mention that I was wrong about the returned value of a yes/no field. Although the database does contain blank, 0 or 1, it must be processed before it reaches the template into Yes or No.

I have one more thing I need to do, I have to put yet another loop in to ensure that the table's text is not printed if the member has no subscriptions. I'll work on this next then upload my code for your final scrutiny.

Thanks again for your help and patience.

Nick
Back to the top
 
Posted
Rating:
#100332
Avatar

Community saint

That's good news TQ, I thought you were getting stuck there for a moment.

TQ said

Before I finish with this subject I thought I'd better mention that I was wrong about the returned value of a yes/no field. Although the database does contain blank, 0 or 1, it must be processed before it reaches the template into Yes or No.
That is definitely what is happening.

What was confusing me was that Yes/No should have been obvious, after all that's what is displayed on screen, so I would have expected you to see in on screen at some point, along with actual field name you used. So the only scenario were you would never see that info should have been:

temp1024 said

2) In the profile you are looking at, you have not explicitly chosen Yes or No for QRZ_Listing or any of the other Yes/No fields, so you will not see anything until you edit the profile and change them to Yes' or No's.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: