What's the Best Approach: Conditional Processing or Separate Pages?

I am in the process of creating a resource section on a website that will showcase various types of information, such as guidebooks, blogs, and corporate documents. Each type of information has unique requirements when it comes to layout and presentation. A blog page may have a more casual design, while a corporate document would require a formal layout.

This situation has raised some questions in my mind:

  1. Should I create separate pages for each type of information, like blog.htm, document.htm, guides.htm?
  2. OR Should I opt for a single dynamic page called information.cfm, for instance, where conditional logic is used to display each type of information differently? For example:

<cfif URL.DocType = 'Guide'>
    // Display layout/divs suitable for Guides
    <cfelseif URL.DocType = 'Corporate'>
    // Display layout/divs suitable for Corporate documents
    </cfif>

The second option personally seems most logical to me, but I want to ensure if it is the correct approach?

Answer №1

It appears that there are several potential paper types available (let's simplify them into two specific types).

You have a collection of links on a webpage:

The links are as follows:

super professional paper 
bloggie type paper
another super duper pro-paper
something real formal
something personal-able and bloggie-ish

For example, if you have index.cfm along with header.cfm and footer.cfm included. In index.cfm, the header will be expecting a url variable: url.professionalPaper, which can be either 0 or 1 based on the link you create (explained below) - '0' for 'professional', and '1' for 'bloggie'.

<cfinclude template="header.cfm"> in your index.cfm file and 

In the header.cfm, include this:

<cfparam name="url.professionalPaper" default="-1">

If defaulted to '-1', it means to 'expect nothing' is incoming (in your perspective).

Your list of links will be structured like this:

<a href="?professionalPaper=0&paperID=1234">professionalPaper</a><br>
<a href="?professionalPaper=1&paperID=1111">something personalable and bloggie</a>

If you wish to reference the current page, such as index.cfm, you can do something like this:

<cfif structkeyExists(url,"paperID")>
    Hi, you are reading a paper...but which one?
    <cfswitch expression="#url.professionalPaper#">
        <cfcase value="0">
            Yes, we are presenting a pro-paper targeted at professionals!
        </cfcase>
        <cfcase value="1">
            This is a sentimental blog post. I'm feeling emotional.
        </cfcase>
        <cfdefaultcase>
            Wait, what? -1 in url.professionalPaper means you need to choose a paper!
        </cfdefaultcase>
    </cfswitch>
</cfif>
<br>
Here are some links:<br>
<a href="?professionalPaper=0&paperID=1234">professionalPaper</a><br>
<a href="?professionalPaper=1&paperID=1111">something personal-able and bloggie</a>

This is the fundamental concept...and you can modify it as needed.

If you want to redirect this to a separate page like, for instance: pages.cfm, then update your links accordingly.

<a href="pages.cfm?professionalPaper=0&paperID=1234">professionalPaper</a><br>
<a href="pages.cfm?professionalPaper=1&paperID=1111">something personalable and bloggie</a>

Include the remaining logic in that page instead. This way, you have links in index.cfm and your page logic in pages.cfm.

Then your defaultcase statement can look like this:

<cfdefaultcase>
    Wait, what? -1 in url.professionalPaper means you should return to your index.cfm page containing the links (add link to go back).
</cfdefaultcase>

This is a basic overview but I believe you understand the concept and can expand upon it too :)

Answer №2

If you're looking to streamline your development process, I recommend exploring FW/1 or another MVC framework. There's no need to start from scratch when everything you need has already been created:

https://github.com/framework-one/fw1

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for creating a mobile-friendly appointment section on your website

Hey guys, I need some help with a problem I'm having. I created an appointment page that works perfectly on desktop mode, but when I try to view it on mobile, it's not responsive. Can anyone assist me in fixing this issue? Appointment.js Here ...

Encountering foreign characters in MySQL database post data insertion

I am currently facing an issue with inserting data from inputs into my MySQL database using PHP. The problem is that when I view the data in phpMyAdmin, it appears as foreign characters. I have already configured my database to use the utf8_hungarian_ci co ...

Resolving the problem with iterating through $list using SCSS/SASS @mixin

Consider the following list: $box-shadow-properties: -webkit-box-shadow, -moz-box-shadow, box-shadow; I am attempting to create a mixin that iterates through this list: @mixin box-shadow-with-inset($box-shadow-params, $inset-params) { @each $property ...

Different varieties of responsive calendars with built-in memos for various device displays

I developed a responsive calendar with memos for each day. Everything seems to be working fine, but only on two different screen resolutions. When viewing it on my small monitor with the resolution of 1024x768, it displays like this: https://i.sstatic.net ...

Learn how to create a logarithmic scale graph using CanvasJS by fetching data from an AJAX call

window.onload = function() { var dataPoints = []; // fetching the json data from api via AJAX call. var X = []; var Y = []; var data = []; function loadJSON(callback) { var xobj = new XMLHttpRequest(); xobj.overrideMimeType("applicatio ...

What is the best way to add an inset shadow with a transparent background in SVG?

I created a basic SVG Icon, but I'm having trouble adding an inset shadow effect to it. Is there a way to achieve this? svg { filter: drop-shadow(0.1px 1.5px 0.1px rgba(0,0,0,0.5)); } <!DOCTYPE html> <html> <body> <svg width ...

Is there a method to implement lazy loading for the images within the CardMedia component in Material UI?

How can I implement lazy loading for the image within the CardMedia component? Is there a specific attribute I should use or any other method to achieve this? <CardMedia key={cardIndex} component="img" style={{objectFit: 'cont ...

The bootstrap modal display issue: black background visible

In my HTML file, there are two modal dialogs that seem to be causing an issue. Interestingly, whichever modal dialog is placed first in the sequence of the HTML code displays properly when the button is clicked (and vice versa). Both modal dialogs have u ...

Websites are operating at a sluggish pace

Yesterday, out of nowhere, we encountered a vserver issue. If you visit this particular Website: You will notice that it takes forever to load. This problem is affecting all websites hosted on the vserver. I reached out to the Provider to see if there we ...

Issue encountered when trying to import an image URL as a background in CSS using Webpack

I have been trying to add a background image to my section in my SCSS file. The linear gradient is meant to darken the image, and I'm confident that the URL is correct. background-image: url(../../assets/img/hero-bg.jpg), linear-gradient(r ...

Repetitive Anchor IDs and Web Standards Compliance

Today, I encountered the task of converting outdated attributes on a page to make it more XHTML friendly. This led me to consider the anchor tag and its usage: Initially, I had anchor tags in the form of <a name="someName"></a>. However, upon ...

Can someone explain why the min-width property is not being respected by the <input> element?

Visit this link for the code The text field in the provided link should only be 10px wide but it is currently displaying a width of 152px. Here is the code snippet: .input { width: 100%; box-sizing: border-box; } .cont { padding: 2px; } .main ...

Is it possible to get the nth-child() function to function properly in IE8?

When using the CSS pseudo-class nth-child(), I've noticed that it works perfectly in all browsers except for ie8. I'm looking for a solution that doesn't involve using JavaScript or jQuery. Is there a way to make these pseudo-classes work i ...

Tips on customizing the appearance of JFoenix components within JavaFX Scene Builder using CSS

I'm struggling to customize the appearance of a JFXButton using CSS stylesheets. While some properties are working fine, such as background color and size, I can't seem to get font color and weight to apply: .eliminarBtn { -fx-background-col ...

Session does not reflect the correct quantity

I have encountered some issues with my account, so I am currently using my brother's account to access the e-commerce website I am working on. My main concern is regarding the handling of quantities on different pages of the website. The website con ...

Creating a PDF document in Go by combining individual pages with go-wkhtmltopdf

I am in the process of developing a report generator with Go as the server-side language. The report will include a specified header with a logo image, a footer, and dynamic content displayed in a table format. Each page will consist of 20 rows of table da ...

How can you identify the specific HTML page that a jQuery selector is targeting?

In an attempt to create jQuery code that counts the number of <img> elements on a website, I encountered a unique challenge. The website consists of 4 separate HTML pages stored in the same folder on the server. Among these pages, only "pics.html" is ...

Transforming images with Imagick

I've been trying to generate thumbnails from PDF uploads using Imagick. I have a script that is supposed to handle this task, but unfortunately, it only uploads the file without creating a thumbnail. I know some of you may find this basic, but PHP is ...

Can you guide me on setting up a multi-selection option for a field in my Wordpress Theme by Templatic?

My website is http://aisiel.ro, a real estate agency website. Under the slider, there is a search field where we have the option to select an area called "Zona" - Area in English. Currently, users can only choose one area for their search, but I want to ...

Using mix-blend-mode with an SVG image within a colored <div>: tips for applying it to the background color of your HTML

I am facing an issue with a SVG file that has mix-blend-mode styles defined on certain elements. The blending is working properly for the elements inside the SVG, but not for the background color of the HTML <div>. For instance: <!doctype html> ...