1 2 Previous Next 16 Replies Latest reply: Jul 14, 2014 5:41 AM by Sunil Bhatia RSS

    How to display a logo image based on instance(Dev/Test/Prod)?

    KTM

      Hi All,

      I am new to APEX technology.

      APEX version: 4.2

      My requirement is to display a logo image of our application based on instance. I have two images

      1) One for Dev 2) Another for Test Instance

      I also know the instance name for the corresponding environments. now based on these instance name i have to show logo image.

      could some one suggest me how can i achieve this?

       

      Thanks

        • 1. Re: How to display a logo image based on instance(Dev/Test/Prod)?
          fac586

          982035 wrote:

          Please update your forum profile with a real handle instead of "982035".

          I am new to APEX technology.

          APEX version: 4.2

          My requirement is to display a logo image of our application based on instance. I have two images

          1) One for Dev 2) Another for Test Instance

          I also know the instance name for the corresponding environments. now based on these instance name i have to show logo image.

          could some one suggest me how can i achieve this?

          How do you know the instance name? Is it stored somewhere?

          • 2. Re: How to display a logo image based on instance(Dev/Test/Prod)?
            KTM

            Hi fac586,

            Thanks for the replay. Yes i will update my profile.

            i am able to get the instance name by executing below sql statement

            "select name  from v$database"

            this will returns whether it is dev instance or test.


            Thanks

            Kotresh

            • 3. Re: How to display a logo image based on instance(Dev/Test/Prod)?
              Sunil Bhatia

              Hi,

               

              Why don't you put a case statement here only to load your custom global image in a global variable, and use that custom variable in your page template? Something like,

               

              select (case when name = 'DEV' then 'pic1.png' when 'TEST'then 'pic2.png' else 'pic3.png' end ) into :G_IMG_NAME  from v$database;


              Where G_IMG_NAME is your global item. Now you can use this global item to set image source tag with header. Does it sound good?


              -- Sunil Bhatia

              • 4. Re: How to display a logo image based on instance(Dev/Test/Prod)?
                KTM

                Hi Sunil,

                Thanks for the replay.

                I have created one global item in my application to load logo image(say AI_IMAGE), but i stuck in setting the above case statement  as you mentioned in page template.could you please tell me the steps to set condition for global variable ? once i set case statement for global variable can i put below condition in logo text box?

                 

                #WORKSPACE_IMAGE/&AI_IMAGE._logo.png

                i have stored my images under shared components.

                is this the correct approach?

                 

                Thanks

                Kotresh

                • 5. Re: How to display a logo image based on instance(Dev/Test/Prod)?
                  Sunil Bhatia

                  We can have different approaches for this:

                   

                  1. It can be set as you mentioned above, but it should be like "#WORKSPACE_IMAGES#&AI_IMAGE._logo.png" Please note the changed # and extra 'S' from your statement.

                  2. As i said, it can be done in your page level template as well. Go to you theme specific page template and search for #LOGO# Instead of #LOGO# you can write your custom <img src="#WORKSPACE_IMAGES#&AI_IMAGE._logo.png" alt="logo"/>

                   

                  Message was edited by: Sunil Bhatia

                  • 6. Re: How to display a logo image based on instance(Dev/Test/Prod)?
                    KTM

                    Hi Sunil,

                    I have done below steps

                    1)I have created application item AI_IMAGE

                    2)Created Application Computation to set the value for application item

                       - Computation Item : AI_IMAGE

                       -Computation point : On new instance (new session)

                       - Computaion type : Item value

                     

                    Computation

                     

                    select (case when name = 'DEV' then '#WORKSPACE_IMAGES#App_Logo_m3.jpg' when 'Test' then '#WORKSPACE_IMAGES#App_Logo_m2.jpg' else '#WORKSPACE_IMAGES#App_Logo_m1.jpg' end ) into :AI_NAME  from v$database;

                     

                     

                    and in the logo text i have put like this

                    #WORKSPACE_IMAGES#&AI_IMAGE.

                     

                    but when i run this the app. there is a null value for image

                     

                    is there any mistakes in the above steps?

                     

                    Thanks

                    Kotresh

                    • 7. Re: How to display a logo image based on instance(Dev/Test/Prod)?
                      Pars

                      Kotresh,

                        There is some easy way to Recognize your APEX dev, qa and prod environments 

                      you can use in your development and test instance.

                      Hope this helps...

                      • 8. Re: How to display a logo image based on instance(Dev/Test/Prod)?
                        fac586

                        This approach follows the principle of separation of concerns, yields sensible default/fall-back behaviour, and after initial implementation only requires maintenance of one component (an external style sheet) to add environments, respond to environment name changes, or change images:

                         

                        1. Create an application item APP_ENVIRONMENT to hold the environment name (note: not the image name).
                        2. Create an On New Instance application computation to set the APP_ENVIRONMENT item value to sys_context('userenv', 'db_name').
                        3. Edit the application page templates, adding the value of the APP_ENVIRONMENT item as a class attribute to the page body element: class="&APP_ENVIRONMENT.".
                        4. Create an external CSS style sheet with environment- and theme-dependent descendant selector rules to set the background of the theme logo element to the environment-specific logo image:

                         

                        /*
                        Set global logo properties and default (production) logo.
                        
                        
                          "a#uLogo" is selector for logo container element. Change as necessary depending on theme used.
                        */
                        a#uLogo {
                          /*
                            Set size of container to the size of the image to ensure the entire image is visible as the container background.
                          */
                          display: block;
                          height: 64px;
                          width: 128px;
                          background: transparent url(production_logo.png) no-repeat;
                        }
                        /*
                          Set development logo.
                        
                        
                          ".dev" is selector for development environment. Change as necessary depending on DB name.
                        */
                        .dev a#uLogo {
                          background-image: url(dev_logo.png);
                        }
                        /*
                          Set test logo.
                        
                          ".test" is selector for development environment. Change as necessary depending on DB name.
                        */
                        .test a#uLogo {
                          background-image: url(test_logo.png);
                        }
                        
                        
                        
                        


                        Note that using an external style sheet is not compatible with storing images in the APEX repository and referencing them using #WORKSPACE_IMAGES# substitution string. Doing so requires the style sheet to be implemented for each page template, which defeats the purpose of using this approach. Images must therefore be stored in the file system or XDB repository.

                        • 9. Re: How to display a logo image based on instance(Dev/Test/Prod)?
                          KTM

                          Hi ,

                          Thanks for the reply. I will try your approach as well.

                          could you please tell me what is wrong in my approach ? since all our images are in shared components so i started following this.

                          if you could suggest, where i might doing wrong then that would be great!.

                           

                          Thanks

                          Kotresh

                          • 10. Re: How to display a logo image based on instance(Dev/Test/Prod)?
                            fac586

                            982035 wrote:

                             

                            Hi Sunil,

                            I have done below steps

                            1)I have created application item AI_IMAGE

                            2)Created Application Computation to set the value for application item

                              - Computation Item : AI_IMAGE

                              -Computation point : On new instance (new session)

                              - Computaion type : Item value

                             

                            Computation

                             

                            select (case when name = 'DEV' then '#WORKSPACE_IMAGES#App_Logo_m3.jpg' when 'Test' then '#WORKSPACE_IMAGES#App_Logo_m2.jpg' else '#WORKSPACE_IMAGES#App_Logo_m1.jpg' end ) into :AI_NAME  from v$database;

                            Does the name value on dev and test really change between upper case and sentence case like that ('DEV'/'Test')?

                             

                            and in the logo text i have put like this

                            #WORKSPACE_IMAGES#&AI_IMAGE.

                             

                            but when i run this the app. there is a null value for image

                             

                            is there any mistakes in the above steps?

                            You are duplicating the #WORKSPACE_IMAGES# substitution string in the computation logic and the logo properties. Only use it in one place—the logo properties would be best.

                            • 11. Re: How to display a logo image based on instance(Dev/Test/Prod)?
                              KTM

                              Hi,

                              I already corrected duplicate string mistake and name values i mentioned above are for examples. I double checked, i have set proper values for names.

                              when i run the app and used firebug to check the value of Logo here is what i am getting

                               

                              <a id="uLogo" href="f?p=100:36:104892668395591">

                              <img src="wwv_flow_file_mgr.get_file?p_security_group_id=2206524032546857&p_fname=">

                              </a>

                               

                              do have any idea on this?

                               

                              Thanks

                              Kotresh

                              • 12. Re: How to display a logo image based on instance(Dev/Test/Prod)?
                                Sunil Bhatia

                                By your debug message, clearly Value in the global variable is not setting. I am sure AI_IMAGE is null at the time when logo is getting created.

                                 

                                -- Sunil Bhatia

                                • 13. Re: How to display a logo image based on instance(Dev/Test/Prod)?
                                  fac586

                                  As the computation runs at the On New Instance processing point, have you logged out of the session and reconnected to get a new instance of the application?

                                  • 14. Re: How to display a logo image based on instance(Dev/Test/Prod)?
                                    KTM

                                    Yes you are correct. The Global variable value is null.

                                    I was trying to set at page template level.I navigated to themes under shared components and searched for #LOGO#  but i got empty result. so stuck with the approach which you said.

                                    Hence still trying with the old approach and i have also all the settings which i did for application computations to set Global variable AI_IMAGE.

                                    is there any mistakes in those steps. Please correct me.


                                    Thanks

                                    Kotresh

                                    1 2 Previous Next