Load dynamic wiki pages on TABS

LabKey Support Forum (Inactive)
Load dynamic wiki pages on TABS saravanan adaikkalavan  2015-06-10 12:58
Status: Closed
 
Hi,

    I'm creating a new TAB and trying to load a wiki page in that tab. I have attached an image in which it shows the options to embed a wiki page. Can I load the wiki page dynamically through code in the tabs? I mean, can I pass a parameter and load the appropriate wiki page in the tab?

Thanks!
 
 
Jon (LabKey DevOps) responded:  2015-06-10 13:56
Hi Saravanan,

Can you provide us some more details regarding what you're looking to do?

By default, a newly created tab will have no webparts inside. So if you add a wiki webpart, it will automatically bring up the screen you're seeing right now unless you have a default wiki page that will load instead (the webpart will identify the default wiki page due to the name of the page being called "default").

If there is no default, you would have to click that choose an existing page option if you wanted to use one of your existing pages to populate that webpart.

Are you asking if you could already have a pre-determined wiki page load (not necessarily the default) within that webpart once the tab is made?

Regards,

Jon
 
saravanan adaikkalavan responded:  2015-06-11 06:11
Yes. When I click the tab, I need to display different wiki page with respect to the user status. Say for example, I have 2 wiki pages A & B. If user is in the state 1, I should display A. Or if the user is in the state 2, I should display B. Is there a way I could implement this?

One solution I was thinking is to add a temporary wiki page to check the state and embed the appropriate wiki inside this page. Is there any other better solution that could be implemented?

Thanks!
 
Jon (LabKey DevOps) responded:  2015-06-11 11:23
Hi Saravanan,

I'm not sure what you mean by "state 1" and "state 2", but if the "user status" you're referring to has to do with permissions or some type of access, then there is a roundabout way to have a wiki page display based on access.

So if you do the following:

1. Create or identify the wiki pages that you want to display to users based on their permissions/status/etc.
2. Create a default wiki page so the wiki webpart will use this automatically.
3. Within the default wiki page, setup your code so that it will identify those users based on their permissions and then load the respective wiki page you want that user to see.

Here's what I did for one customer of ours. I created two pages, one called "thisPageIsForProjectA" and the other called "thisPageIsForEveryoneElse". I then made a default wiki page with the following in it:

<script type="text/javascript">
LABKEY.Security.getUserPermissions({
        containerPath: '/Project A',
        success: onSuccess,
    failure: onError
    });

    function onSuccess() {
        var wp = new LABKEY.WebPart({
        partName: 'Wiki',
        renderTo: 'wikiDivTag',
        frame: 'none',
        partConfig: {name: 'thisPageIsForProjectA'}
        })
     wp.render();
        }

    function onError() {
        var wp2 = new LABKEY.WebPart({
        partName: 'Wiki',
        renderTo: 'wikiDivTag',
        frame: 'none',
        partConfig: {name: 'thisPageIsForEveryoneElse'}
        })
     wp2.render();
        }

</script>

<div id="wikiDivTag"></div>

So this code:

- Get the permissions for the user that is view the page right now.
- Determines whether they've got access to the Project A project.
- Loads the appropriate wiki web part based on that permission.

I believe that this code sample should get you on the right track with what you're trying to do.

For more information on our Javascript API and the security endpoint, please checkout the following documentation: https://www.labkey.org/download/clientapi_docs/javascript-api/symbols/LABKEY.Security.html

Regards,

Jon
 
saravanan adaikkalavan responded:  2015-06-11 12:37
No Jon. I'm trying to create a step by step process on the tab. Like the user start the process on step 1(consider this as the basic information). Then after completing this, they move to the next page where they would be asked for the phone number to verify(step 2). I need to load the phone number requesting and verification page in the records tab after the first step succeeds.

Hope I'm clear with scenario.

Thanks!
 
Jon (LabKey DevOps) responded:  2015-06-11 12:51
Hi Saravanan,

That sounds very different than what you described earlier when you were asking if you can pre-load a wiki webpart based on a "user status".

Are you are trying to use the tabs as apart of a series of steps, like this?

- First tab (aka Step 1) -> Enter information
- Second tab (Step 2) -> Enter more information

If this is what your idea is, you might want to consider using our Survey Designer instead.

Take a look at this link along with the video. I think this might be a better solution here.

https://www.labkey.org/wiki/home/Documentation/page.view?name=surveys

Regards,

Jon
 
saravanan adaikkalavan responded:  2015-06-11 13:06
Thanks!