Custom Image on Portal Login

Posted by awbranch on 06-Nov-2014 17:50

One of my customers what's to have a custom image on the headers of all of their portal pages. Suppose I manually change the "headers and footers" of the portal page for this particular tenant. If later on they install an update to my application will that customization get overwritten?

If so what are some alternative approaches? 

Posted by Godfrey Sorita on 10-Nov-2014 07:38

Have you considered using hosted files? This way you only need to use a single token to access the URL of the uploaded image (e.g. {!#HOSTED_FILE.20930#url}). 

You can upload hosted files from the application settings and the tokens are available from the header and footer's Template Helper.

If you still want to use the EVAL block, then you should do the following:

  1. Create a text field to store the file upload URL.
  2. Create a trigger with "After Create" and "After Update" timing that will set the token#url value to the text field.
  3. Update your selectQuery to fetch the value of the text field.

Godfrey

All Replies

Posted by Godfrey Sorita on 07-Nov-2014 07:58

Hi Andrew,

Yes - the customization will be overwritten. Suppose the application XML of your tenant does not have a custom image in their portal header, the application being updated will also have the same.

To exclude the portal from being updated, simply uncheck the portal's checkbox prior to the application update.

Regards,
Godfrey

Posted by awbranch on 07-Nov-2014 11:23

Well suppose there are updates bug fixes in the portal. I don't want to not push it out to everyone. So I don't think that will work.

The approach I've taken is to create an object called "portal_config" and I've added an image field to it called "logo". I've added View permissions to the Query API.

Now in the headers and footers, I want to reference this object. It doesn't seem that I can reference it directly, so I tried adding it to a loop as follows:

{!#LOOP_BEGIN.all#25535446(1)}

{!logo#html}

{!#LOOP_END.all}

Unfortunately it doesn't appear that LOOPs work at all inside of the Header and Footers. I'm running 2.2.2.0, is that a known issue?

However, I was able to get a EVAL block to work, so now I have some code like this.

#EVAL[

var arr = rbv_api.selectQuery("select logo from portal_config", 1);

return arr[0][0];

]

This returns a string that looks like this:

#Thu Nov 06 18:22:38 EST 2014 fileSize=8141 origFileName=Portal Logo.png contentType=image/png fileName=tmp_456523793550806486.png

How should I turn that string into a URL, by parsing it and building it manually, or is there an easier way?

Posted by Godfrey Sorita on 07-Nov-2014 11:39

You can store the image on SETTINGS object. First, you need to access its object definition and create an image upload field. Then upload the image from Setup Home -> Administration Setup -> Settings.

You should be able to access the logo from any component (e.g. header, footer) using its token: {!#SETTINGS.bg_image#url}

Posted by awbranch on 07-Nov-2014 15:52

Settings isn't going to work. I don't have access to change its view pages.

Is Managed [x] Only publisher can modify this page. I'm creating a 3rd party Rollbase app and distributing via XML.

I'd like to get back to my previous approach which works nicely, except when reading the image via a selectQuery it returns that string.

Posted by Godfrey Sorita on 10-Nov-2014 07:38

Have you considered using hosted files? This way you only need to use a single token to access the URL of the uploaded image (e.g. {!#HOSTED_FILE.20930#url}). 

You can upload hosted files from the application settings and the tokens are available from the header and footer's Template Helper.

If you still want to use the EVAL block, then you should do the following:

  1. Create a text field to store the file upload URL.
  2. Create a trigger with "After Create" and "After Update" timing that will set the token#url value to the text field.
  3. Update your selectQuery to fetch the value of the text field.

Godfrey

Posted by awbranch on 10-Nov-2014 14:15

Thanks Godfrey.

The "After Create" and "After Update" timing that will set the token#url was a clever approach that worked for me.

This thread is closed