Portal Mods

Portal Modifications scaffold in the rXg admin console

Portal Mods provide comprehensive portal customization capabilities through five modification types:

Modification Types:

  1. View Override: Replace entire view templates (e.g., login.erb, session_info.erb)
  2. Partial Override: Replace specific partial templates (e.g., _welcome_message.erb, _footer.erb)
  3. Image Override: Replace portal images and assets
  4. Variable Customization: Modify theme colors, Bootstrap variables, and appearance settings
  5. Controller Action: Add custom Ruby code to execute new controller actions

Content Modes:

  • HTML Mode: Direct HTML/ERB code editing with full template access
  • Rich Text Mode: WYSIWYG editor with image upload and formatting tools

Appearance Settings:

  • Light Mode / Dark Mode: Portal appearance themes
  • Color Customization: Bootstrap theme colors, button colors, background gradients
  • CSS Variable Override: Complete control over portal styling

Example Portal Mod

In this example Portal Mods will be used to change the greeting on the default portal, the login types and the logo on the splash and landing page. To change the default greeting (Good Morning, Good Afternoon, and Good Evening) create a new Portal Mod. The Name field is arbitrary. Select the Splash portal the change should be applied to. In the Partial Override select welcome_message from the drop down. In the HTML field the code for the welcome_message view is displayed, and can be edited.

Create Portal Modification form with welcome_message partial selected and default code displayed

If the goal is to change the message that is displayed in the afternoon the following code can be changed on lines 31 and 41 "greeting_afternoon = _('Good Afternoon')". If "Good Afternoon" is changed to "Hello, Good Afternoon", then in the afternoon the message displayed will change from "Good Afternoon" to "Hello, Good Afternoon".

Portal Modification code showing the modified greeting_afternoon line

This will result in the following change, the first image is the unmodified portal and the 2nd is with the modification.

Portal displaying original Good Afternoon greeting

Portal displaying modified Hello, Good Afternoon greeting

It is also possible to replace the code entirely. Here is an example where the code has been erased and replaced with custom code to display a static greeting message.

Portal Modification with custom Hello World HTML code replacing the welcome message

This results in the following to be displayed regardless of time of day.

Portal displaying Hello World! as the static greeting message

Using Portal Modifications the operator of the rXg can also change which login options are displayed overriding the default portal that displays login options based on the configuration. The operator may only want to display a click through option and PMS login for example. The below image shows the default portal with the login options displayed dynamically based on what is currently configured on the rXg.

Portal with all login options displayed: Free Access, Access Code, Room Login, and Log in

To only display the free options an the PMS room/name login, create a new Portal Modification. The Name field is arbitrary, enter a name for the record, check the Splash portal(s) this modification will apply to. The Mod type field should be set to Partial Override , and the Partial Override field should be set to login_forms_conditional. To display the free option and PMS room/name option on the portal remove or comment out the section of code for the login option that is to be removed.

Portal Modification with login_forms_conditional partial showing commented out login options

Detailed view of the code with Token Login and Account Login sections commented out

Now the portal will only display the login options we put in the Portal Modification.

Portal now displaying only Free Access and Room Login options

In this last example we will change the logo displayed at the top of the portal page.

Portal now displaying only Free Access and Room Login options

To change the logo, create a new Portal Modification , give it a name, select both the Splash and Landing portals the logo will be changed on. Change the Mod type field to Image Override , a URL can be entered load the image from a remote location, for this example we will use the Image field and click the Choose File button and select the file to be used. In the Image To Replace field enter "default_icon.svg". Click Create.

Create Portal Modification form with Image Override type and default_icon.svg as image to replace

Now the logo displayed at the top is changed. Note: that if this is done on a cluster the configuration will be pushed to the portal on each node, there is no need to create a record for each node in the cluster.

Portal displaying the new custom logo replacing the default rgNets logo

In this example, a template will be used to upload an image to replace the default logo. Below is the template that will be used, the variable data will be populated with the image after it is run through a Base64 Image Encoder, note for the sake of space the data variable has been truncated. For this example https://www.base64-image.de was used to convert the rgnets_logo.png to Base64.

<%  
  mod_name = 'Replace Logo'  
  image_to_replace = 'default_icon.svg'  
  filename = 'rgnets_logo.png'
  data = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAawAAABXCAYAAABY6nHCAAAEsmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGF"  
%>


PortalMod:  
- name: <%= mod_name %>  
  image_to_replace: <%= image_to_replace %>  
  image:  
    data: <%= data %>  
    filename:  <%= filename %>

Navigate to System::Backup and create a new Config Template.

Config Templates scaffold with Create New button highlighted

Give the Config Template a name, and enter the code into the Config field. Check the Apply Template box, this will save the template and apply it at the same time. Click Create

Create Config Template form with PortalMod YAML code and Base64 image data

Config Templates showing the Replace Logo template successfully applied

Next navigate to Policies::Captive Portal , the template has created a Portal Modification that can be used to replace the default_icon.svg file.

Portal Modifications scaffold showing the Replace Logo entry created by the template

Example: Using Actiontext With Portal Mods

In this example we will create a Portal Modification that will allow us to quickly and easily modify the information found in the footer of portals all from a single location. Operators can use this to change or modify all or a select group of portals all at once. There are two portals that will be modified in this example.

Custom Portals scaffold showing Portal1 and Portal2 that will be modified

Navigate to Policies::Captive Portal. First we need to create a Portal Modification that will display the custom view we are going to create to display our footer information.

Portal Modifications scaffold with Create New button highlighted

Give it a name and select which portals this Portal Mod will be applied to. In this example we want the information we are including in the footer to display on each page, so we will select both portals under the Custom field. If we only want the information to display on the splash portal then we would select both portals under the Splash field, and the same could be done for Landing as well. Since we are modifying the footer we need to specify that under the Partial field. When you start to type the name of the Partial it will give you a list to choose from, we want to select footer. For this first Portal Mod leave the Content mode set to HTML. Here we are creating a div that will display the view we will create in the next step, this also allows us to give it some formatting like centering the text. See screenshot below, click Create.

Create Portal Modification form with footer partial and render_portal_partial code in HTML

Next create a second Portal Modification , this one will contain the information we want to display in the footer. Give it a name and select which portals this content will be added to. For this example I am selecting both portals under the Custom field. In the Partial field we are going to enter in the name of the view we are calling in the previous step, in this example that was footer_content. Change the Content mode to Rich Text , we can now enter in the content for our footer. Images can be included as well by clicking the paperclip icon and selecting an image. Click Create.

Create Portal Modification with Rich Text content mode showing help desk message and logo

Now if we visit the default portal which the Portal modifications haven't been applied to we get the following.

Default portal without the footer modification applied

If we visit portalone or portaltwo we will see that the mods we created show up because these were the portals we selected.

Portal1 showing the custom footer with help desk message and logo

Portal2 showing the same custom footer with help desk message and logo

We can take this a step further by editing the Portal Modification record that contains the phone number and image and change it so that it only applies to portalone, and we will create another record that applies to only portaltwo. Edit the record and unselect portaltwo.

Edit Portal Modification showing only Portal1 selected with updated content

Now create a new Portal Modification selecting only portaltwo, and change the content. We will move the logo above the other content for this one.

Create Portal Modification for Portal2 with logo above the help desk message

Now if we look at portalone, we get the following result.

Portal1 with its custom footer showing help desk message then logo

And finally looking at portal two we get the following result.

Portal2 with its custom footer showing logo above help desk message

Example: Change Background Image

In this example, we will use Portal Modifications to add a background image to the default portal. Because the default portal's background gradient is defined solely using CSS rules, we will need to add some CSS in order to set a background-image. We will create two portal modifications to accomplish this. The first will serve the purpose of storing the background image, which will be referenced by the second Portal Mod's CSS rules.

Portal Modifications scaffold with Create New button highlighted

Give the portal mod a name, which should reflect the purpose of the modification (this name will be referenced by our second Portal Mod). For this example we will use "Default-bgimage". Since this Portal Mod won't be rendered directly, there is no need to select any portals in the Custom, Splash, or Landing fields so those fields should be left blank. Next, click on the Choose File button and select the image to be used for the background. Click Create. Note: recommended formats are .jpg for reduced size or .svg for better resizing.

Create Portal Modification for background image storage with image file selected

Create a Second Portal Mod, which will modify the CSS Partial. Give the portal mod a name, again it should reflect its purpose. Select the Splash and Landing portal to which it will apply. Enter "CSS" in the partial field. Add the following code to the HTML(ERB) field:

<style>
  body, body.bg-dark {
    background-image: url(<%= rails_blob_url PortalMod.find_by(name: 'Default-bgimage').image %>) !important;
  }
</style>

Click Create.

Create Portal Modification for CSS partial with background-image CSS code referencing the image

We should have two Portal Modifications now, and when we view the default portal it will have our new background image.

Portal Modifications scaffold showing both the bgimage and bgcss modifications

Default portal now displaying the custom background image


Cookies help us deliver our services. By using our services, you agree to our use of cookies.