ASP.Net MVC Blog content storage - asp.net

I'm creating a blog in asp.net mvc for learning purpose so please no answers telling me i should use an open source blogengine. I need to understand how is the blog content going to work. So i have a table called "Blog" with a column called "Content". The "Content" will hold the blog i.e. text and images etc. Now i have the following questions:
What should be the datatype of content.
Is this the correct way of doing it i.e. saving the blog in a record.
What are the contants of this blog i.e. is it html with rich text and image urls and how does it actually work, i.e. where are these image urls be pointing to and how will my application render it.
Thanks.

Though you certainly could make it work with a single table, you probably want to use several tables to store the content. A basic implementation might look like:
One table for the periodical list of blog entries you have with columns for blog ID, perma-link/url, etc
One table for the tags associated with each blog id
One table for the blog entries themselves, consisting of a blog ID, blog body, etc
One table for comments, with blog ID, comment ID, comment body, etc
Everything would be linked together in the tables by the various IDs (blog ID, comment ID, etc) and your engine would load and render the body elements as specified by the ID requested.
Images, attachments, etc would be stored on a fileserver, and the rendered content would have hyperlinks to them.
This is by far a simplistic envisioning of it, and doesnt cover many aspects or issues. For instance, if you plan to store content such as images, etc in your DB you will need to have unique pointers for those, tables for those items and a way to resolve them as part of your MVC framework.
Start simple, and build up from there if you are just learning. Just build each table as you need it and go from there.

Not sure which DB you are using but assume SQL server for this example. You can store your blog content in a field as nvarchar(MAX). i dont see any issues with doing this

Related

Is the best way to update sections of a dynamic webpage - by rewriting the file every time?

At my company (a custom retail e-commerce website) we have a homepage with various sections on the page for promotions/sales/events. These sections may appear in any order, one after the other. The order of the sections are saved in a database table called mainpage_sections with an order column (int).
The present method we use for updating the homepage when the order of sections is changed, is by running a callback method that automatically rewrites the aspx View file itself, in HTML, with the new order of the sections. It does not pull the sections from the database and dynamically render them according to their order.
This struck me as being opposite to best principles and very messy. I asked why we didn't use a database read instead, but I was told that since this website is visited thousands of times a day, and the order of the sections rarely changes, it makes more sense to update the file itself, instead of running thousands of extra database reads just for people visiting the homepage of the website.
Does this approach make sense? What is the best-principle, recommended approach here? Is something like output caching a better choice?
Overwriting a code file does seem weird. What if you stored the ordering in a separate JSON file, and only overwrote the JSON file?

Convert query parameters to "pretty urls"

I have an Episerver site with a JobDetailsPageController with a Index method that takes a jobId parameter and creates a view with some details about that job. The urls looks something like this: https://hostname/<root-depending-on-site-tree>/jobs/?jobid=44.
What I would like is having urls on the form .../jobs/manager-position-telco-44, essentiallly creating a slug of the job title and appending the id. I have done this in the past using standard ASP.NET MVC Attribute Routing on a non-Episerver site, but EpiServer has a routing of its own that I don't know too well and can't figure out.
Also, adding non-query strings after the slash consistently sends me (no surprise) to a 404 page, so I would need to somehow customise this behaviour. I need to use EpiServers standard routing to end up at the right "parent", but ignore the latter part (the pretty bit).
Is it possible to create such urls on a normal page in page tree in EpiServer? I do understand it is possible to create static routes, but this node can be moved around like any other page so I cannot avoid EpiServer.
Please see this blog post. What you're looking for is partial routing.
#johan is right, partial routing is one way of doing this. Just wanted to add other possible solutions that might or might not match your needs.
Import data as content
Instead of serving content dynamically, you could consider importing your job ads from whatever source you have directly in content tree as separate pages below particular root page. That would give you a lot benefits - pages would be cached, it would support multiple languages, editors would see content directly in EPiServer CMS, data could be adjusted manually, etc.
This would be a good solution if your data does not change often and you need to provide a way for editor to create a new job ad manually as well.
Implement you own content provider
Another way to serve your dynamic data to EPiServer is to write your own custom content provider. You can find documentation here: http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/7/Content-Providers/Content-Providers/
This solution requires more coding and is more complex, but it has some benefits as well. If one wanted, it would be possible to not just serve content from external data source, but also update that data by changing values directly in EPiServer UI.

Drupal - Show content on specific page

Am I able to add the following field to a content type, so that each piece of content I create can be conditioned to a page?
Or is there a module to extend Publishing Options, where by it adds all the pages I have created (just like 'Promote to Front Page')?
If not, why is no one doing this? As a new user to Drupal this seems like it would be a handy operation. (I have already tried this module but it doesn't achieve the results I'm after).
If none of these solutions are available, what would be the best alternative way of doing this?
I've posted this question on Stack Exchange for Drupal but I need a quick answer and there seems to be a bigger community here :D
You should use Context. With Context, you'll be able to manage contextual conditions and reactions for your drupal like Regions.
Have you used Views? it is one of the most common used drupal modules. It doesn't extend publishing options directly but it does replace it in a way. You can say by example put a list of al content-types: your_own_Content_type that have the publishing options of promoted to front-page. then sort them by title, date, what ever you like.
you could also create only one view and create multiple blocks out of it. you have to understand the logic of drupal: if you want different blocks on different pages, you have to create the different pages AND different blocks
create the view for one type of content-type and make one block out of it. put this block on the desired page. All your other blocks are made with the same view, just adjust a condition in your view and create a new block out of it. You should also put all your blocks in the same region, and set the to the right pages
here you can find a lot of documentation if you run into any problems... drupal.org/project/views
Views is the best at creating a slideshow of images or any type of data on your site.
Used in combination with nodequeue it might offer near or the full functionality you are trying to achieve (check this out ... and this too) - but I don't understand your question entirely.
By my opinion Views is too complicated task for much simple request.
There is a few ideas for solution:
Easy way - You can create a specific template file or add some if statments to the node.tpl.php(specific tpl better)
For minor changes - Create a new context with "path" filter and "theme html" reaction, than hide the field by the css
Best but complicated(large usages) - create a new "view mode" and implement the display by new "hook_menu".
~ Almog

How to save asp.net html articles

I have asp.net web page on home page i want to add articles and news.
Which would be better way for saving articles store it on database or .xml or .html?
I think you should store it in a good normalized table structure. Put different meta information in different columns and put the article as html in a column.
If you were to store it in a file I'd recommend saving it in XML so that you can save meta information along with the article. But as you are using Database, meta information can be saved in other columns. So plain HTML is completely okay.
I'd say for any homepage type applications, saving content in files (be it xml, html or plan text) is enough.
Scott Hanselman's blog uses dasblog, which doesn't needs a database and simply stores all contents in text files in a folder.
Really? Thats like "what is better; a red or blue car". That said, db driven designs are more common

Selecting Modules for site design and content

I am creating a real estate listing website and am confused with modules I might need,
Is there a way, as I'm creating a node and writing a description, to also on the same node creation page to upload pictures, input the address for the google map, and add a snippet for the amenities.
I was thinking of using fields, and make each attribute just php code with variables like $address or $amenities
Then create blocks that would have the required css/javascript in them to just drop the variables into.
This way I can position the different attributes on the page on different columns with the ease of blocks.
Are there any modules that might work better for this?
If you're using Drupal 7, Fields can handle most of what you want. See the "image" type for fields in order to store pictures. For addresses, try http://drupal.org/project/addressfield or the development version of Location. For amenities, you could use the node body or another text field. Then you can look into Drupal theming in order to get the values and position them elsewhere - no need for blocks.

Resources