Page Extension Kickstarters
If you’re trying to do something on a specific page, chances are that you’re going to need to work some of the information on the page. This article walks you through some useful page extension code that will help you get started.
Finding the basic information about the current user, logged in user and a owner could be done in two different ways. One by finding the HTML element that contains the value on each page using jQuery/JavaScript and another by reusing the available properties in the context of the rendered page. This context is provided through the nVelocity view engine and has some useful helper methods. You can write JavaScript with the nVelocity tokens, and these will all be replaced as the page is rendered and before it is sent to the client.
Finding the ID of the currently logged in user
Javascript, using jQuery:
var link = jQuery("#LoggedInAs").attr("href");
var id = new RegExp('[\\?&]id=([^&#]*)').exec(link)[1];
You can also get it from the context of the nVelocity engine at the time the page is rendered:
var loggedInUserId = "$loggedinuserid";
Finding the Name of the Currently Logged in User
Javascript, using jQuery:
var loggedInUserName = jQuery("#LoggedInAs").text();
From the context of the nvelocity engine at the time the page is rendered:
Finding the Branded Owner
Javascript, using jQuery:
from the context of the nvelocity engine at the time the page is rendered:
Finding the Role of the Current User
Javascript, using jQuery and it’s only possible on the overview page
You can get the current user role name or id from the context on any page by loading a helper method available in the controller:
Helper Methods Available in the nVelocity Context Through Controller Parameters
You can use these methods to get objects back, or to execute any nVelocity logic:
Here is an example how to add the nVelocity logic in your page extension. If current owner is top owner run a javascript code:
Loop through current user invoices
Â