Products

Solutions

Resources

Partners

Community

About

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

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsLanguage PacksLanguage PacksLocalResourceFile property in PortalModuleBaseLocalResourceFile property in PortalModuleBase
Previous
 
Next
New Post
1/12/2006 10:42 PM
 

That property builds the resource file name by appending its ID to the path.

I'm not sure about the ID approach, since appart from regular module loading, this won't work with specific IDs.

For instance, this does not work with User Controls, nor does it work with module controls in Inventua's Shadow module or I guess any module of that kind.

Personaly, I found it useful to define a base control with the following properties:

Public Property MyFileName() As String

Get

If Me._MyFileName = "" Then

Me.MyFileName = Me.GetType.Name.Replace("_ascx", ".ascx")

End If

Return Me._MyFileName

End Get

Set(ByVal Value As String)

Me._MyFileName = Value

End Set

End Property

Public Property LocalResourceFile() As String

Get

If Me._localResourceFile = "" Then

Me._localResourceFile = DotNetNuke.Services.Localization.Localization.GetResourceFile(Me, Me.MyFileName)

End If

Return Me._localResourceFile

End Get

Set(ByVal Value As String)

_localResourceFile = Value

End Set

End Property

I've read that GetType is pretty quick unlike some other Reflexion methods so that could be an alternative, what do you think?


Jesse
CTO - Aricie
 
New Post
1/13/2006 3:15 AM
 
I'm not sure I follow your question here.
I've never had a problem on LocalResourceFile not being correctly initialized. In skin.vb there's code:
 ' set the control ID to the resource file name ( ie. controlname.ascx = controlname )
' this is necessary for the Localization in PageBase
 objPortalModuleBase.ID = Path.GetFileNameWithoutExtension(objModule.ControlSrc)

that will handle this just fine.
As for regular controls you just need to make them inherint from UserControlBase and add a property:
        Public ReadOnly Property LocalResourceFile() As String
            Get
                Return Services.Localization.Localization.GetResourceFile(Me, MyFileName)
            End Get
        End Property

that points to the correct file. Look at all the controls under \controls folder.

Vicenç Masanas
Banyoles, Girona - Spain

Disgrafic.com    PSD to DNN
 
New Post
1/13/2006 5:48 AM
 

My point is not really about the efficiency of that property on regular skin loading use. I never had any problem in that case neither.

It was more on the fact that maybe we could avoid having that property from PortalModuleBase rely on the InjectModule method from the skin.vb.

This is just that if relying on something generic as suggested, we could have both PortalModuleBase and UserControlBase expose that same property as somthing generic and independant from the control's life cycle (and maybe have the first one inherit the second one)

You can argue that PortalModuleBase controls are tied to the skin.vb so it is not a problem, but I can see points for developers to be willing to shortcut that, such as for Inventua's Shadow Module or some other multi module containers module.

If we can avoid that dependency, shouldn't we do so?

Furthermore, the MyFileName attribute is usually hard coded for user controls. This is to my opinion the thing that both module and user base controls could provide generically without the need to rely on the control's ID.

Finally it might be time to abstract a little more the base classes by adding some more standard functionalities (and as said above, with a richer UserControlBase, PortalModuleBase could inherit it bringing some more coherence) . It is once again to my opinion one of the things DNN code lacks.
I think this also true for entity classes, which don't rely on any base class or interface. Having a base EntityInfo class base on the CSLA.Net framework could be a suggestion for bringing more power to the Business Layer. Bringing similarly a more powerful base class to the presentation layer is what this post is about.


Jesse
CTO - Aricie
 
New Post
1/13/2006 7:34 AM
 
I agree with you on the fact that having the filename for the usercontrols hard coded on the file is not a good approach.
Nor the lack of that property in UserControlBase.
This is something we need to revisit.

As for the code to get the file name your approach seems intersting, i'll give it a try. Another possible option for user controls is to use the Attributes collection, I think we can get the filename for there too.


Vicenç Masanas
Banyoles, Girona - Spain

Disgrafic.com    PSD to DNN
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsLanguage PacksLanguage PacksLocalResourceFile property in PortalModuleBaseLocalResourceFile property in PortalModuleBase


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