I need to develop a whole section of a website (around 10 different pages) as a DotNetNuke module. The site will be using DNN as the CMS, where editors will manage HTML content for most of the website (exception that section I'll be developing).
I've already made a rather extensive research on DNN Module Development (even watched some recorded Webinars by DNN Corp). Unfortunately, most of what I could find online is about developing simple, widget-like modules. Also, most of it uses a step-by-step "how to use visual studio to acomplish x" approach, while I was trying to understand how DNN works. So it seems I have to figure it out for myself...
At this point I'm already somewhat familiar with DNN, and I see several different solutions to my problem:
Creating a module for every page on my custom section. I don't like this idea very much, specially because I have code that need to be shared across multiple pages.
Developing a single module with several User Controls inside (one for each page), and use custom module settings to let each page know which control to display.
Develop a "bogus" module that will work as a library, and additional modules for each page.
Develop the library module, then use the Razor Host Module and Razor scripts for the views (I don't need/want WebForms on my app).
So I decided to ask you guys for advice. Which is the the preferred way to go? Maybe none of the above? I know all four options above should give me the result I want, but I also don't want to go against the "DNN way" too much...
I wouldn't recommend #1 (multiple modules) or #3 (also multiple modules) at all, and though #2 (single module w/ module level setting that determines view) is definitely a solid option used widely by DNN module developers, it sounds like you'd prefer #4 (Razor) over #2 because you like the development style.
So - I'd recommend going with the Razor approach, which though it seems like you understand the approach just fine, I wanted to elaborate on for posterity:
Build a library (assembly/DLL) to encapsulate all of your reusable business logic
Build out Razor views for each page that make use of that logic and render your data on the page
Drop the Razor Host module on each page that you need it and point it to the correct view
That should work out quite well.
I'm assuming you're looking at developing your software in the "Web Site Project" style. I'll like to recommend that you look at the "Web Application Project" style of doing things.
If you have shared functionality in a library, feel free to build an assembly and drop it in the bin folder, from there, it will be picked up by DNN and it will run in the http context, which is great!
Build your module in one project and package the different modules in your DNN manifest.
Hope i'm not talking about what you understand.
Added another answer, it's a post in itself.
Modules - That's a term that's very loosely used by all of us.
Clearer Definitions
Package = Zip file (Not Module)
Manifest = .DNN file
The manifest allows you to define Modules(group of View/Edit/Settings) user controls as a single installation package.
In the DNN 3.0 manifest, if you're still in this format, you'll notice that a basic single installation package is structured like this (briefly)
<dotnetnuke version="3.0" type="Module">
<folders>
<folder>
<name>Side bar Navigation</name>
<modules>
<module>
<friendlyname></friendlyname>
<cachetime>0</cachetime>
<controls>
<control>
<title>View</title>
<src>DesktopModules/Module/View.ascx</src>
<type>View</type>
</control>
<control>
<key>Settings</key>
<title>Settings</title>
<src>DesktopModules/Module/Settings.ascx</src>
<type>Edit</type>
</control>
</controls>
</module>
</modules>
<files>
...
</files>
</folder>
</folders>
</dotnetnuke>
So that above defines a Single Module in an Installation Package.
In the context of a blog, you would have 2 modules
Blog Display Module (displays a selected blog or just the whole lot)
Sidebar Navigation Module (Helps you
to display quickly the blogs you've
written for an any period of time)
What you can do is to package the Blog Display Module in the manifest in a copy of <folder></folder> and then the Sidebar Navigation Module in another copy of the <folder></folder> structure.
For example, this project has 7 modules; Side bar navigation, custom search module, blah blah blah
<dotnetnuke version="3.0" type="Module">
<folders>
<folder>...</folder>
<folder>...</folder>
<folder>...</folder>
<folder>...</folder>
<folder>...</folder>
<folder>...</folder>
<folder>...</folder>
</folders>
</dotnetnuke>
1 Installation Package (Which means 1 Web App Project)
7 Modules
One assembly to place in the bin/
All code is shared and you can then inherit from other library references to develop further.
They have different views, names, friendlynames but all share one common <foldername>
The KEY is in the Packaging.
<folder>
<name>BlogDisplay</name>
<friendlyname>Blog Display</friendlyname>
<foldername>WebLog</foldername>
<modulename></modulename>'
'<folder>
<name>BlogSidebar</name>
<friendlyname>Sidebar Navigator</friendlyname>
<foldername>WebLog</foldername>
<modulename></modulename>
It'll look something like this! that's where foldername is. It defines where in DesktopModules your module will be installed to.
In DNN 5 books, the Web Site Project method of development is still in use but when you're participating in development on the Core Modules, you'll find that the projects are in Web App Project development style, which is better, because all your code-behind is in an assembly and not exposed as source code on the web.
You're definitely on the right path.
Related
My question is similar to here: ASP.NET System.Anything is not defined
I am in the process of converting a website project to an MVC 4 project. To do this, I created a new MVC project and imported all of my content from the previous website. Both projects are in VB, and I'm using Visual Studio 2010 SP1, with both the MVC 4 update and TFS 2012 update applied.
I now have errors popping up when I build the MVC project. Things like "Type 'System.Web.UI.Webcontrol' is not defined." When I hover over the error, two of the prompts I get to fix it are
1) Change 'System.Web.UI.WebControl' to 'Global.System.Web.UI.WebControl'
2) Change 'System.Web.UI.WebControl' to 'WebControl'
Both of these seem to fix it, but does anyone know why I can't use "System.Web.UI.WebControl" to refer to this class? I'd rather not change all of my code... there are 100s of thousands lines in there.
Update: Outside of the System and System.Web.UI namespaces, I can also drop the 'System.'. So 'System.Drawing.Color' would become 'Drawing.Color'.
There exists another namespace containing System in your solution somewhere (e.g. Abc.System.def) - probably in a referenced library. After the conversion, the project file probably imported the prefix to System in said namespace (e.g. Abc), so when you type in System, it resolves to Abc.System.
I posted this question before I had whittled down as much of the compile errors as possible.
It appears that after I had removed all the System. references from the previous App_Code classes, the real errors started appearing. There were all sorts of messages about aspx controls not existing.
Ultimately, it seemed that I needed to right-click on the .aspx pages from my website project and choose 'Convert to Web Application.' This generated a .aspx.designer.vb file with the asp.net control declarations in yet another partial class.
After doing that for all pages, I am now able to use System. throughout the app.
To others who've asked, this System. error was only affecting the non-page code. .aspx, .aspx.vb, .ascx, .ascx.vb, .ashx, etc., files were not affected.
This does make some sense, anyhow, as I had previously pulled in all the App_Code libraries prior to pulling in the pages, and the site compiled. After importing the pages and their code behinds, the order of the errors was just odd. But I stuck with it and found the underlying cause.
Thanks for the willingness to help. If you have any other questions, I'd be glad to respond.
Hi i want to know what is meant by modules in a project??how they are classified and how many modules we can have in a project?can anyone explain with simple examples??What modules we can have in a typical online shopping website?
In .net context I believe one can draw 2 meanings not sure what specific you are looking for.
One is modular programming by following design principles like "Separation of concerns", "Single Responsibility", "loose coupling". This means divide you code into classes based on these principles and further group these classes again based on these principles into modules.
In ASP.NET or C# or in general we create class library projects and use them across the entire project. Like all the logging functionality is put in some classes and these classes are include in an class library project which can be called "Logging module". Whenever you need logging in any of the project you can include this module and use the functionality.
Some examples:
Web module for HTTP requests ( The WebApp)
Repository and Data access Layer modules. (DAL code)
Models module containing all the business entities.
WebService modules for integrating with other apps.
Logging for debugging and problem identification
Infrastructure/Utility modules for utility like functionalities and
application configuration.
Business logic modules.
Transaction gateway module.
Other way to define module in .net is they are PE files and I believe they have extension .netmodule which contain Metadata but they do not contain the assembly manifest. To use a module you have to create a PE file with the necessary assembly manifest.
Create a module:
csc /t:module ufo.cs
Create assembly using the module:
csc /t:library /addmodule:ufo.netmodule /out:airvehicles.dll helicopter.cs
Above 2 commands are from this link
The module is an external code that you plugin on your site and runs in order to do some actions.
(source: codeguru.com)
We make and use modules to have the ability to share the actions of the module with others with out giving the source code, and vice versa, we use modules from other that we do not have access to the source code. Or we can simple use module for have the ability so simplify our code and remove it easy if we do not need it.
We can have as modules as we like, but each module place extra overhead on our code - after all is need to make more thinks there.
More about modules: http://www.codeguru.com/csharp/.net/net_asp/article.php/c19389/HTTP-Handlers-and-HTTP-Modules-in-ASPNET.htm
How to create module: http://support.microsoft.com/kb/307996
I've struggled with a better solution for the following setup. I'm not actively working on this, but know some that might appreciate other ways of handling this.
Setup:
Tridion-managed page has a single "linked list" component Linked list
Single component has component links to other components in Tridion
Linked-to components often link to multimedia component (mm)
An XSLT component template (XSLT CT) renders XML with above content and with links to PDF
XSL document() function used to grab embedded (linked-to) content, all content converted to XML nodes and attributes
TCMScriptAssistant namespace with publishBinary() publishes related PDF and other media
Page template just outputs the result of the CT
Business requirements:
improved publishing (last I worked on this, some of these files created a 2GB publishing transaction because of the PDFs)
published XML content file must reference the associated PDFs; hyperlinks work but identifiers might not help because of...
no Tridion content delivery APIs, mainly for independence from the storage database but also to avoid Tridion-specific code on the presentation server (loosely coupled setup and less training for developers)
The biggest issue is the huge transport package during publishing. The second problem is publishing any of the linked-to PDFs will cause the page to republish.
How could this setup be improved or re-engineered, preferably without too many changes to the existing templates, though modular templating could be considered.
Dynamic component presentations could possibly work, but would need to be published to the file system and not use dynamic linking or broker objects (e.g. no criteria filters, binary metadata, etc).
There are indeed 2 questions. I will handle them in reverse order.
To prevent the page from being republished when you publish a binary, you can use the event system in older versions of Tridion (pre-2011) to turn off link resolving, or with newer versions you can use a custom resolver to prevent this. There is an article by Nuno which explains this(http://nunolinhares.blogspot.com/2011/10/tridion-publisher-and-custom-resolvers.html)
Your second one is a bit tougher, in no small part because of your criteria for not using the SDL Tridion CD APIs. I would have suggested publishing the binaries separately (this would keep the file size down of your transaction package), and using Binary Linking to resolve the paths at request time.
Given this is not an option, I think the only was I would approach it would be to still use dynamic component presentations, and then use predictable unique file names for the PDfs (i.e. use something like 317-12345.pdf based on the URI), and use one directory for all the binaries. That way you could enter the paths to the binary using your XSLT template, as you know where the binaries will be located later. You could then use a custom resolver to publish the binaries when you publish the main list component or page.
Hope that helps
Chris
I am inheriting some ASP.NET code (I am an OS guy, not a web dev (yet ;-)). The solution has been re-factored and there are multiple projects (libraries and asp.net sites) in it. Aside from the libraries, there are two asp.net projects (called MAINSITE and SUBSITE). Only MAINSITE is being used as the official site (as an asp.net site), and MAINSITE has a depency on the code in the SUBSITE asp.net site, but doesn't use the site itself. I am trying to figure out how to clean this up and convert SUBSITE into a library.
My quick question is, whenever I debug the MAINSITE (set as default), it runs two asp.net processes: MAINSITE and SUBSITE. And so, at the very least, how can I avoid this? Is there a quick/temporary solution to this?
My detailed question is this:
What makes an asp.net site an asp.net site? For instance, in C the difference between an dll and exe could be defined (superficially anyway) as the presence of a main, and potential export information for the library (among other things, of course). If I were to convert an exe to dll I might:
1. remove the main code
2. make sure the public interface was correct (and exported correctly)
3. convert the makefile to build a dll rather than an exe.
Can someone point me to some similar steps for asp.net to .net lib?
Maybe:
1. get rid of index.aspx
2. get rid of web.config
3. any *.cs files to remove?
4. how do I change the properties?
5. any gotchas?
Thanks so much for your help.
Details: Visual Studio 2008/.NET 3.5
There are many, many components to make an application run as an ASP.Net application. However, in terms of your actual Web Application project, there's really not that much difference between it and generic library code except for the fact that much of your code relies on the existence of the HttpApplication runtime.
Any code that utilizes the System.Web (especially System.Web.UI) is going to be suspect in terms of having this dependency. For example, all the code in page or webcontrol event handlers (Init, Load, PreRender, etc.) relies on the fact that there is an HttpHandler (running inside an HttpApplication) raising these events. If you run the same WebControl out of a library that's not in an ASP.Net project, none of this will ever happen and the control will be useless. However, that exact same library would be quite functional if executed in the context of an ASP.Net process.
It really boils down to what process you're running the library in. In most cases, ASP.Net processes are spawned by IIS, although it is possible to host an ASP.Net process in other types of programs as well.
There isn't a simple 5-step process for converting a web project to a library unfortunately. But as a rule of thumb, webcontrols, .aspx and .ascx codebehind aren't going to convert.
For a more detailed look at what makes code into an ASP.Net program, see Rick Strahl's "A Low level look at ASP.Net".
If you go to "File" > "New" > "New Project..." and then click on the (assuming you're using C#) "Visual C#" in the list on the left, you're given the ability to create a "Class Library" project. You can extract all the relevant code to one of these and then reference in in your "MAINSITE".
You will need to reference it in the "References" section of your MAINSITE project and may need to import your library project using the import keyword.
I would like to create an installer that installs 6 websites, all of which rely on a data access library. So the solution contains 6 web applications, and 1 class library.
Question is: how can I accomplish this without using custom actions?
So far, the only thing I've thought of is to make merge modules out of the web app projects, each of them throwing in the primary output of the class library project, and then making a main installer that has all the merge modules.
I would put each website in a feature that way you could give the end user the control over which website they require, if that is an option.
Although, you'll have to repeat the same type of code for each website in their respective.wxs file.