Adding DNN module error when control has key assigned - dotnetnuke

I'm creating a module and I was able to add a user control as a view type and everything worked. I want to add a second control, also as a view type, but that's where trouble begins.
If I just add the new control to the module definition, it displays only that control and not both. If I remove it, the original control displays fine. Going back into the module definitions, I went to the module controls and assigned values to the respective Key properties. When I save, my module disappears from the page it was displayed on. If I try to add it again, I get "Object reference not set to an instance of an object."
It was through trial and error I discovered if I remove the key, I can re-add the module it works again (at least as described above).
Essentially I want multiple views for my module where individual views can be displayed on different pages (much like the Blog module). I'm not creating a package for distribution so I'm almost to the point of just creating a separate module, but where's the learning experience in that?
I've searched for a tutorial on creating a module with multiple views with no luck. Can anyone provide some insight?

I got round this issue by using the modulesettings to choose which display I wanted for that instance, in my case I used the setting to determine which front end was visable and which was not aswell as the backend code.
Another option is to have one view ascx which is a placeholder and inject either ascx view you want based on a modulesetting.
I have used both these methods before and both work well

In DotNetNuke there can only be one 'View' so if you want to make something that displays different views depending on the situation you have to create a Dispatch view. So depending on your module setting like you have, or a URL parameter, cookie, session, something in the primary View gets another user control to display what is needed.
This post talks about it a bit Dispatch View
Sounds like you found a solution that works for you.

Out of the box DotNeNuke also supports using multiple views, however as soon as you switch to a different view the module enters "Isolation Mode", where it becomes the only module visible on the page.
If this behavior would work for you, then you can add multiple controls, the FIRST control you add without a key, the secondary controls you add with a specific key. You can then use NavigateUrl or EditUrl to construct the link to the specific controls.
From an "edit" perspective, the use of this pattern ensures that your users have a consistent environment with only your module. From a View perspective the usage of other patterns is more commonly a "better" choice.

Related

Salesforce modify standard forms for lead generation

I would like to change the standard form for creating a lead a bit. Actually i just want to add a link to another form to allow the user to quickly jump to it (our appexchange app). I thought i could use visualforce page and override the "normal" lead creation mask. But I believe this won't work since i probably need to implement an exact copy of the normal form source code with the link additionally and also need to wire it correctly to the actions.
Since i can't find the source for the "new lead" page, it seems quite hard to do it that way. Is there any other way to add a link to a stanadard/existing form in SF ?
Any hints?
You should be able to cheat. Create a VF page with 2 links, 1 to your form, 1 to normal "new Lead" page. Read up about {!URLFOR} and the optional "no override" param (that just adds &nooverride=1 to the url), should take users to normal form.
Failing that you might be able to use lightning:recordForm (pick Aura or LWC) to magically reuse the page layout crafted by admin. You'd marry that to your VF page using Lightning Out - or just make your override completely an aura/lwc? It's marked as beta so I don't think you'll be able to package this as your appexchange app... Maybe provide the component and instructions for admins how they can copy paste your code to their own VF page and bypass the packaging woes.
If you really want - you should be able to recreate standard Lead layout in your VF using Layout class too. Sounds ugly but well, last resort before completely forgetting about the standard layouts, teaching admins about fieldsets and stuff?
Are you sure this is the right way to attack the requirement? Override (especially via VF) will be slower and if you ever create leads from related list (say Campaign -> members -> new -> add inside lookup?) you lose some flexibility. I'd make 2nd "New" list button and drop it in Lead tab or maybe add component to bottom utility bar?

How would I repeat content on pages (and modify some) in DNN

I am trying to figure out how to place content across pages as well as modify only some of the "same" things.
For example, I have two services. Let's say I want to add a small box on the right panel. On the pages directly under the root of my site (Home, About Us, Contact Us), I want this box to contain generic information (We provide services for . . . ). On the pages related to service one (the service one page and sub-pages), I want that same box to contain pretty much the same text except changing it specific to service one (Our service one solution...). The same for service two and it's sub-pages (Our service two solution...).
To change content I think I'd be right to leave "Make a Copy" checked. However, I don't want this box to appear on every page, just one's that I choose (whether grouped or not; i.e. root pages, service one pages, service two pages).
How can I accomplish this? I'm working directly using the DNN 7.01 admin/host interface - I'm imagining I can accomplish this by creating separate .ascx files, but for this I think it defeats the purpose.
Thanks.
What you will want to do is use the "Add Existing Module" function to handle this.
For example for the content that you want to be the same, add it to the "main" page and setup the content. Then on the pages that need to have THAT version use "Add Existing Module" and add the module from the "main" page.
Then, when you have a variation that is to be shared across other pages, repeat this process.
DO NOT use the "Display On All Pages" option though as more than likely that will trash things!
I've not a lot of experience as Mitchel, and his answer seems the way to go. But as an alternative (when dealing with LOTS of modules with static content), I found using a template page with all the modules (and content within) helps to group things so that you can use that template for sub pages that have the same content. In other words, only the actual content pane for a sub page needs to be created because you are copying all the other "widgets" you have on your page.

Should we create custom pages for all objects?

I noticed that salesforce doesn't allow to override control function for all objects.
Say if you want to do something whenever objects get saved there is no way to attach the action
unless you create a custom page and include either standard controller or extension. Or if you want
to add the same meta-tag on all pages I run into this limitation. Is there better way to do this?
Generally - no. Roughly speaking if Salesforce doesn't allow you to do something it usually means there's pretty good hint you're doing in it wrong. I realize it sounds like I'm a fanboy but in reality - can you expand your question with concrete example why would you want to do something like that? For example governor limits are evil, annoying etc. - but they force you to write effective code that doesn't strain the database too much.
if you want to do something whenever objects get saved
That's what triggers are for. Ask yourself a question if the "action" you need to make should happen only from web UI or also when performed from API (mass data load, a smartphone application etc).
if you want to add the same meta-tag on all pages
You could maybe pull off similar result by adding a component to the sidebar. It won't cover all cases (like accessing Reports/Dashboards) but it's hard to say more without knowing what you're really after. Then again - custom VF page overrides won't help you when it comes to Reports either.
I wanted to add this as a comment, but was unable to.
Anyways, For the example that you mentioned in the comment, You can add that jQuery plugin in the Home page side bar component and activate the plugin only on those custom objects where you wnat to run this plugin. You might already know that we can deduce which object a record belongs to by looking at the 1st 3 letter of the record Id, using this logic, check if the record belongs to the custom object you want your plugin to act on and run the plugin.
But As eyescream has pointed out adding script in side bar has its own limitations: you cannot use the global variables , side bar components are not loaded on the reports and dashboard tabs etc.
-ಸಮಿರ್

how modules can linked

In my dotnetnuke application i added so many modules, i want to display the content in the contentpane when i clicked on the items that is in in the left / right pane. Can you give me the code for navigating the modules..
There are a few options available to you for passing information from one module to another. The simple way is to put the shared state on the querystring.
The more robust way is to use Inter-Module Communication, which basically requires one module to implement the IModuleCommunicator interface, allowing it to send massages. You can then implement the IModuleListener interface in other modules to react to those messages.
It's hard to answer this question because I don't know what you're doing exactly. What is the module in the left pane, and what is the module in the content pane? How are they interacting?

Customising a DNN Module

I am trying to modify a standard dnn module (Links) that comes with dnn. Essentially what i want is the make a copy of the current links module and change the look of it. I had a look inside the links module, and each link is placed in a table cell. I want to set the background of table cell to be an image and have a mouseover effect.
How can I do this? Is it possible with containers? I do not want to recode the links module functionality.
Also I want to create another type of a links module. I require this module to have a title, a sub-title (which is optional), then followed by the links. Since the tables in the original links module does not allow for a sub-title, i am thinking i have to create a new table and manage it separately. Is this the correct path to go down?
You should be able to make the changes to the table cell by editing the file /DesktopModules/Links/Links.ascx
In order to add the Sub-Title field, you would need to make a log of changes. To completely clone the module, you would need to make database changes, rename all (or most) classes used in the Link module, and make a copy of the Links folder to hold your new files. It sounds like you're going down the right path for this change. This will require a different level of effort than simply adding a background image and an onmouseover affect on the existing links module.

Resources