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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How To: Adding an Image with dynamic Url ?How To: Adding an Image with dynamic Url ?
Previous
 
Next
New Post
7/22/2006 10:44 AM
 

Hey there,

I am a newbie considering DNN. Just installed DNN 4.3.3 and configured my site. Looks cool and all.. :) But I want to add an image which has a dynamic url based on today's date. What is the best approach to implement this image, let's say, on the Home page? I do not mean the code for getting the correct ImageUrl, but how to do it in DNN...

grtz,
Octavie

 
New Post
7/22/2006 9:58 PM
 

Presumably you have a URL end-point that's an ASPX page that renders the image. The simplest way is to add a Text/HTML module and embed an <img> tag referencing the page that will render the image.

Nik

 


Nik Kalyani
Co-founder
DotNetNuke Corporation
Blog | Twitter | FaceBook
 
New Post
7/23/2006 5:00 AM
 

Hey Nik,

Thanx for replying. What I wanted to do is to show Garfield's Daily Comic. That url is changing every day based on today's date... that's the dynamic part...

Since I have little knowledge about the DotNetNuke Framework I puzzled for hours last night. So, here is my solution...

On my Home tab I put a Media Module and set the basic settings. In the Page_Load of the Default.aspx I placed this code:

'Setting Url Garfield Daily Comic
If PortalSettings.ActiveTab.TabName = "Home" Then

'Get all modules placed on the Home tab
Dim homeModules As ArrayList = PortalSettings.ActiveTab.Modules

'Loop through the found modules and get the Media module for Garfield
For i As Integer = 0 To homeModules.Count - 1

Dim moduleInfo As DotNetNuke.Entities.Modules.ModuleInfo = CType(homeModules(i), DotNetNuke.Entities.Modules.ModuleInfo)

If moduleInfo.FriendlyName = "Media" Then

'Getting and setting the info is done by the Media Controller
Dim controller As New DotNetNuke.Modules.Media.MediaController
Dim mediaInfo As DotNetNuke.Modules.Media.MediaInfo = controller.GetMedia(moduleInfo.ModuleID)

If mediaInfo.Alt = "Garfield" Then
   mediaInfo.Src = GetGarfieldDailyComicUrl()
   controller.UpdateMedia(mediaInfo)
End If

End If

Next

End If


There is also a private function to set the correct url for the image. So... this works, but is it the correct way to do it? Somehow, I've got the feeling there is a more effecient way to do it...

grtz,
Octavie

 
New Post
7/23/2006 7:56 AM
 

Ah...dynamic URL...Javascript to the rescue. Something like this in a Text/HTML module should work:

<script language="Javascript">
   var garfieldUrl = "http://whatever/blah/blah" + "dynamicPart";
   document.write("<" + "img src=\"" + garfieldUrl + "\">");
</script>

The DotNetNuke portal's strength is its ability to allow content management without changing the underlying framework code. When extensibility is needed, it is possible by adding custom modules or skin objects. Most experienced DNN users will give you the same advice -- don't change the DNN core unless you really, really need to because it will make upgrades more challenging. While the source code is there for viewing and re-compiling, it's better to use it as a learning tool, and to use an existing module or add a new module rather than changing the framework code.

Nik

 


Nik Kalyani
Co-founder
DotNetNuke Corporation
Blog | Twitter | FaceBook
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How To: Adding an Image with dynamic Url ?How To: Adding an Image with dynamic Url ?


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