Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically generated graphic content... Good Practice?

Status
Not open for further replies.

marthirial

IS-IT--Management
Jan 29, 2005
20
US
This is more of a advise request than help.

Is it a safe/good practice to create graphic areas of a webpage dynamically. In other words, I have a recordset in MS SQL that has the HTML code to create a menu (tables, graphics, links, etc). that will be served along other dynamic content so it will create the impression that this menu is closely related to such content.

Am I putting a big load into IIS? the SQL dB or because is fairly small amount of code and the images are not coming from the dB but being reference only, I can get away with it?

Thanks for your comments.
 
i would suggest not doing this, updating the html may be harder than expected, also seems like more work - you have to create add/edit/delete to place the code into the db - when you can just place it directly to the page.

Also what happens if their is asp scripts withih the html
 
marthirial,

Personally (for the framework of the site) I would not store HTML 'snippets' in the database. This adds complexity and effort in just the simple loading of the page - and for what benefit ? as per Stevens msg above

However, it can be useful to have menu systems or other dynamic settings stored as actual data fields/records - as this would allow for dynamic selection of content using WHERE clauses etc. This data would ideally be selected and rendered by a common include file into the standard page framework.

The problem with this is the number of requests to the database - depends on your set-up but this can be a greedy consumer of resources for many page requests/hits. kind of a decision of function over performance - but this can be minimised with certain DB's, methods and hardware set-ups.

An alternative that I have found works well is the use of Application or Session Variables - as part of the standard loading of the site (i.e. in global.asa Application_OnStart ), load from either a database or from a file a data structure that represents your menu system - e.g.:

Code:
<menuMap id="mstr-appmenu" name="ExampleMaster" version="1.0" URLBase="[URL unfurl="true"]http://www.example.com">[/URL]
	<module id="dir" loc="/mydirectory/" name="My Directory" href="/mydirectory/home.asp" acclvl="0" colourScheme="std">
		<menu id="dir-menu" name="My Directory" href="/mydirectory/home.asp" acclvl="0" showAs="min" type="top" icon="/imgs/mnu_MyDirectory.jpg"  displayAs="Image">
			<menuitem type="link" link="/mydirectory/search.asp" name="Search" acclvl="0" target="_self" />
			<menuitem type="link" link="/mydirectory/browse.asp" name="Browse" acclvl="0" target="_self" />
			<menuitem type="link" link="/mydirectory/add.asp" name="Add" acclvl="0" target="_self" >
				<subMenu id="dir-add-menu" name="Add SubMenu" acclvl="0" showAs="min">
					<submenuitem type="link" link="/mydirectory/add.asp" name="add it.." acclvl="0" target="_self" />
					<submenuitem type="link" link="/mydirectory/add2.asp" name="add again.." acclvl="0" target="_self" />
				</subMenu>
			</menuitem>
			<menuitem type="link" link="/mydirectory/review.asp" name="Review" acclvl="0" target="_self" />
		</menu>
		<popup>
			<popupitem/>
		</popup>
		<toolbar id="dir-tb" name="Directory Tools" showAs="min" acclvl="0" script="/inc/scripts/dir_script.js">
			<toolitem id="dir-tb-print" type="tool" name="Print" icon="/imgs/icon_sml_print.gif" displayAs="both" onclick="printPage();" acclvl="0" />
			<toolitem id="dir-tb-save" type="tool" name="Save" icon="/imgs/icon_sml_save.gif" displayAs="both" onclick="savePage();" acclvl="0" />
			<toolitem id="dir-tb-space1" type="spacer" />
			<toolitem id="dir-tb-help" type="tool" name="Help" icon="/imgs/icon_sml_help.gif" displayAs="both" onclick="openHelp();" acclvl="0" />
		</toolbar>
		<sidebar id="dir-sb" name="" acclvl="0" colourScheme="std">
			<sideitem id="dir-sb-topsvc" type="include" parameter="/inc/sidebar/topservices.asp" showAs="min" acclvl="0" />
			<sideitem id="dir-sb-comparebasket" type="include" parameter="/inc/sidebar/comparebasket.asp" showAs="min" acclvl="0" />
                        <sideitem id="hme-sb-onlineusers" type="appvar" parameter="currentUsers" value="%#% Users Online" acclvl="7" />
		</sidebar>
	</module>    etc.......

Here it has a module with menus, sidebars,toolbars and even popups defined. But it can be very simple and just have a list of links with a permissions level and image url etc.

As this is stored in the Application variable it's accessible on every page and requests the data from memory, which is much faster than any db or filesystem.

To selectively retrieve the right items on the menu for a user, you can use MSXML or whatever parser you fancy to access the DOM - using something like XPath :

Code:
sPath = "/menuMap/module[@acclvl <= " & sSecLvl & "]/menu[@acclvl <= " & sSecLvl & "]"
set menuset = root.selectNodes(sPath)

You can even set it so that ASP checks to see if the session variable has this menu structure in, and use that (so you can make it user specific.. i.e. load at login) or default to the standard one. (though be careful with storing every users menu config in the session variable as it will consume a lot of server memory)

If your database supports it you could retrieve the recordsets as XML and store as-is, or convert it through ASP.

Remember that any processing other than just reading the HTML and sending to the response buffer will add an overhead to the resource consumption of the server.. but as sites need to function (and look good), as well as be quick, the main aim is to gain the right balance, and then optimise the technical delivery of the design aspiration.

Just a thought though - there are other ways to do it, but just consider the scope of the development, and the time you have to implement it - 'is this a sledgehammer & nut situation?'. Also, there are probably free 'menu systems' out there that you could use.

Good Luck..!

Damian

A smile is worth a thousand kind words. So smile, it's easy! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top