Where should common static resources (images, js, css, etc) go in DotNetNuke? - image

Is there a recommended location to store static resources (images, css, js, etc) in a DotNetNuke 5.x installation?
There are /images and /js folders as well as a /Resources folder that contains resources. There appears to be some overlap as MicrosoftAjax.js is in multiple locations (but might be different versions?). I also could put resources in a /DesktopModule/ModuleX location.
Does anyone know if there is a difference in using any of these folders?
I kinda like the idea of all static resources being under a common folder (/Resources) so I could set caching rule headers, permissions, etc on them in one place.
Has anyone used a separate image server to serve DotNetNuke static content?
Pros and Cons of a separate image server (e.g. images.mydomain.com)?

If you own the entire DNN installation, then it can certainly make sense to consolidate all of your resources into one place (whether its the Resources folder used by DNN, or a different folder that DNN doesn't know about). If you're developing a module that will be installed onto a site that you don't totally own, then the considerate thing to do is to constrain your resources within the DesktopModules folder for your module.
Some things to consider with regards to DNN folders:
If you have content under a module's folder, uninstalling that module will give you the option to delete that content. This can help you keep things clean and organized, or it can make it can be dangerous if you have multiple module definitions sharing the same files... (Even more dangerous can be the uninstall SQL scripts; make sure you don't accidentally uninstall a module which has an uninstall script attached)
You can use the DNN file manager to upload/delete/rename files within the Portals directory, so it may make sense to put files there if site administrators should have control of them
Putting content outside of the module's folder will make it slightly more difficult to link to (especially if it's on a portal specific folder, i.e. you have to ask the PortalSettings object for the path every time)
It's uncommon to keep resources outside of the module's folder, and so may cause confusion if you bring an experienced DNN developer into the project

For skins and containers, you can use their own folders under the Portals directory. As bdukes said, this way site administrators can control them within DNN.
For modules, I have used the module's folder and module.css for defaults that can be overridden by skin or container css. This works because skin and container css are loaded after the module.css.

Related

Multiple sites using 1 code base, best setup to be able to update all sites at once for core issues, yet each site has it's own customizations?

I have an app built on laravel and am using Bitbucket to manage versioning. Currently I'm running multiple sites from this one code base/branch. I'm wanting to have the ability to change the colors for each site as well as add some custom code for some of the pages. There are core parts of the site that will never change unless all the sites need to be updated. What is the best way to set this up in Bitbucket so that if I need to make an update to the core code and push it to all the sites while having the ability to customize certain portions of each site?
I’m in a similar boat and I solved this by creating a new value in the .env file: APP_BRANDING, which is different for each site. In the config/app.php file I have a line like this:
'branding'=> env('APP_BRANDING', 'default');
Then I can check what the value of config('app.branding') is in the code, and (for example) change the footer based off its value.
You don’t need to have just one value for this. It may make more sense for you to have multiple depending on what changes between sites.
You shouldn’t be saving the .env to your version control, so you shouldn’t need to do anything different for deployment.
This is the approach I did with a similar project. It's especially useful, if the amount of customization's is rather huge and includes many files.
I have a folder structure like this (not all actual files and folders are listed here, just important ones):
core/
.git
app/
config/
database/
public -> ../design/public/
resources -> ../design/resources/
routes/
.gitignore
design/
.git
public/
resources/
.gitignore
So I have two main folders core and design. The core folder has symlinks to public and resources located in the design folder. Both folders have their own git repository. You don't even need to exclude public and resources in the .gitignore of the core folder, because git will just keep track of the symlinks not their content.
Of course you can also move single files like special controllers, configs, database seeds, etc. to the design folder as well, if they're not part of the core components of your app.
On your server(s) you deploy the app in the same folder structure. You pull one repository in the core folder and the other in the design folder. You can freely work on the core repository and push the updates to all servers. And if you have design updates for sites you can work on the design repository and push that to a certain site.
Hope you could follow my explanation - for me this scenario works pretty well!

Modular Extensions CI anchors to assets

So, I'm making a CMS at the mo, and using the modular extensions HMVC CI 2.0. It's lovely. I'm wondering the correct method for keeping my assets (js, css, img) related to a module within the module directory.
The problem being, how do I link to these assets? Let's say I'm using a template engine and passing the js files to load for a specific page:
$js[] = 'assets/js/my_js.js';
I suppose I'm asking this all wrong, but is there an easy way to link using the current module's directory?
Thanks in advance.
There's nothing currently built in to CI or HMVC for this.
I prefer not to reference files that are allowed direct access, like images/js/css, from within the application directory. Mainly because:
I don't want anyone to know what the guts of my app look like. By referencing files from directly within a module, you expose your application's directory structure.
I would never do this if I weren't using HMVC
You must now allow direct access to (certain) directories within the application via .htaccess. For security reasons, I prefer to simply disallow the entire thing.
I understand the desire to be as modular as possible, but to me it's not worth this hassle. I prefer to keep a separate directory in a public folder called "modules" (duplicating my application/modules structure), that has nothing but "assets" (css, js, images...).
I'd offer some code but I have no clue how you are adding js/css to your views - it's probably much different than the way I do it. It would be easy enough to write a function to detect the current module, controller, or method and change the asset folder automatically, but this may interfere with other shared assets. I'd suggest writing an entirely separate function for loading assets from modules.

Where should a site's assets go in a MVC website?

Examples given are from Kohana 3, but the question is not limited to the framework.
I've always put my assets in a file structure like this
application
- classes
- views
assets
- css
- js
- swf
- images
-- layout
-- content
system
- classes
I've started reading a few forums where people always mention their assets files are placed in the views folder. This makes a lot of sense to me as these files are tied to the views quite closely (being included by markup). Plus, it will unclutter the docroot.
What is the preferred location of a site's assets? If I do place them under an views/assets folder, where should the actual template files go... under a separate folder like views/templates ?
For ASP.NET MVC
The project template gives you the folders ~\Content and ~\Scripts with the latter containing JQuery.
Why not follow this model, adding additional folders below these if they would otherwise get too many items.
I would stick to the project template unless there is a very good reason to override it (and also override the logic to find views and controllers).
I tend to place mine in the web root (wherever that's defined by the framework) so that I can reference /assets/img/myimage.jpg (or an analogous CSS/JS file, etc.). As Richard suggests, though, I do this because I'm sticking to the framework convention. I'm not familiar with Kohana, but the frameworks I've used extensively all place assets in the web root by convention.

What files in Magento have no purpose being in source control?

I am looking to clean up the file that we store in source control (SVN) for the Magento projects we are working on.
Which files/folder are have no purpose being in SVN, ie the ones are not necessary for the site to function, or are only transient?
So far I have identified
var\cache
var\session
media\temp
var\locks
downloader\pearlib\download
downloader\pearlib\cache
There are some I am unsure about:
var\report
downloader\pearlib\docs
media\catalog\product\cache\
Can anyone provide a definitive list?
http://activecodeline.com/git-ignore-gitignore-file-for-magento-project answers a larger question, but could be helpful none-the-less.
There's a whole bunch of stuff in Magento that doesn't need to be in source control, as it will remain constant (as long as you follow some sane development practices.) The above link goes through all the directories that need not be tracked by source control.
I typically ignore these folders for development, but you may choose to store images if you think it's appropriate:
/var: This is always temp data or data that can be regenerated
/media: These are images and uploads, not really source code, but keep if you want
/downloader: I don't like to use Magento Connect and prefer to install things manually. You can always get Magento Connect elsewhere, so no need to keep it in the repo.
/includes/src: This is compiled source code, you can regenerate if needed. Not really that usefull since we have SSD disks and APC.
We usually have something like:
/app/etc/local.xml
/downloader
/var
/media
Media usually contains images that are configured in admin, like product/category images, logos, CMS images, merged JS/CSS and import/export data I believe.
Some extensions also have files in media that should be versioned (ex. product feed templates)
There is also an htaccess file in var and media so you have to include those.

Can you move (or duplicate) the "special" .Net folders (App_*) in a subdirectory?

It is possible to have extra .Net "special" folders (App_Code, App_Themes, etc.) inside of a subdirectory, rather than in the root?
I am integrating with a CMS that dumps an enormous amount of stuff in the root. I would like to keep all my stuff in a single subfolder, as this will greatly ease my SVN and deployment burden. As it sits, I have to pick through all the stuff to figure out what's mine and what's theirs, selectively committing and ignoring -- it takes about an hour.
I can sure put all my Web forms in a folder. But I have classes in the App_Code and images and stylesheets in App_Themes that I need to deal with.
So, is there anyway to have an additional App_Code and App_Themes in a subdirectory, or are these limited to the root only?
(And, yes, I know about creating an Appication, but this won't work. I need to run in the same context as everything in the root of the site, so it's not really a separate, conceptual application.)
No, you can only have one App_Code folder per ASP.NET application.

Resources