Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Changing header according to userChanging header according to user
Previous
 
Next
New Post
12/15/2008 9:38 AM
 

Hi. I have this bit of code on a site I did for a client,

protected

void Page_Load(object sender, EventArgs e)string newlogo = Request.QueryString["logo"];string currentlogo = logo.ImageUrl;if (newlogo != null)"logo"] = string.format("~/Images/Logos/{0}.jpg", newlogo);"logo"].ToString();if (newlogo == null)if (Page.Session["logo"] != null)"logo"].ToString();else

logo.ImageUrl =

}

}

"~/Images/Logos/nzo.jpg";

Basically, the purpose here is to change the header of the site according to which client accesses it. Each client has a link on his own website to my client's website with a URL parameter that I use to change the header.

Now the client decided he doesn't like the site, so I'm doing basically the very same site with dotnetnuke, with some very minor changes, and the client wants to keep this funcionality.

I have no clue where to begin. I had this bit of code on my master page, and I knew how to access the image control to change its ImageURL parameter.

Now the header is in a media module. How do I access it?? Can this be actually done?? Am I going to win the lottery?? So many questions.

Best

GatoLindo

{

 

 

 

{

Page.Session[

logo.ImageUrl = Page.Session[

}

 

{

 

logo.ImageUrl = Page.Session[

 

 
New Post
12/15/2008 6:09 PM
 

Without the benefit of seeing your actual site, here's a possible solution to your task of dynamically replacing a MEDIA module image based on a querystring value:

  1. Find ID of media module from page source.  This ID will be in the form of:
     
       dnn_ctr{module ID value}_ModuleContent
     
  2. Use the media module's FOOTER setting (SETTINGS->ADVANCED SETTINGS->FOOTER) to insert a javascript routine.  The routine will:
     
    (a) Parse querystring to get your client value.
     
    (b) Update media module's IMAGE tag to reset SOURCE attribute based on client ID value.

The MEDIA module does not assign an ID value to the image so you'll have to drill down from the module ID we got in STEP 1.  Exactly how you drill down will depend on the container you're using (it can introduce any number of tables, DIVs, SPANs, etc), but it would go something close to this:  
 
   < script >
      // Get client ID from querystring
     { some script here to parse the querystring and get your client's ID value }

     // Replace media module image with client image
     tempParentElement = document.getElementById('{media module id value}');
     tempImgElements = document.tempParentElement.getElementsByTagName('img');
     for (i=0; i<tempImgElements.length; i++)
     {
        if (tempImgElements[i].src == '{your default media image URL value}')
        {
            tempImgElements[i].src = '{URL to your client's header image based on client ID}';
        }
     }
  < /script >

That's off the top of my head (I have not run/tested the code).  You might want to add some error trapping but that should be pretty close to working as-is. 

-mamlin


esmamlin atxgeek.me
 
New Post
12/15/2008 6:22 PM
 

I should add:

This would be a great example of a "first DNN module" for you (or anyone) to create.  You could create your own "image display" module and set the image value in the module code (codebehind) which would be much more efficient and robust than changing it after the fact via javascript.  At the same time, it's super-simple so you could learn to create a module without tackling much code complexity.  Here's a good link to get started:  http://adefwebserver.com/dotnetnukehelp/DNN_ShowMeThePages/Default.htm

-mamlin


esmamlin atxgeek.me
 
New Post
12/16/2008 4:45 AM
 

Hi. I used your code with my parameters and a few changes, don't know if it works, js is not really my thing,

< script >
      // Get client ID from querystring
    var clientId = window.location.search.substring(1);

     // Replace media module image with client image
     tempParentElement = document.getElementById('dnn_ctr370_ModuleContent');
     tempImgElements = document.tempParentElement.getElementsByTagName('img');
     for (i=0; i<tempImgElements.length; i++)
     {
        if (clientId != '')
        {
            tempImgElements[i].src = '/Portals/0/' + clientId + '.jpg';
        }
     }
  < /script >

But all I got was the code visible on the footer of my header.

http://test.agripartner.com/welzijnswijzer/Welzijnswijzer/tabid/36/Default.aspx

 

 

 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Changing header according to userChanging header according to user


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out