<分区>
标签 html css coldfusion
我正在网站上构建一个资源部分,该部分将向人们展示不同的信息,例如指南、博客、公司文档。显然,这些不同的信息类型中的每一种都需要不同的布局和页面感觉。博客页面会非常随意,而公司文档会非常正式。
它让我思考:
information.cfm
的动态页面?例如,将使用条件逻辑以不同方式显示每种信息类型。所以像这样: <cfif URL.DocType = 'Guide'>
// Show layout/divs appropriate for Guides
<cfelseif URL.DocType = 'Corporate'>
// Show layout/divs appropriate for Corporate documents
</cfif>
第二个选择对我个人来说最有意义,但这是正确的吗?
最佳答案
看起来您有几种可能的纸张类型(让我们将它们呈现为两种特定类型)。
您在一个页面上有一系列链接:
链接看起来像这样:
super professional paper
bloggie type paper
another super duper pro-paper
something real formal
something personal-able and bloggie-ish
假设您拥有 index.cfm,并且您将拥有 header.cfm
和 footer.cfm
。 index.cfm
header 将等待 url var:url.professionalPaper
根据您建立的链接(见下文)情况,它将等于 0 或 1如果是“0”就是“专业”,如果是“1”就是“bloggie”。
<cfinclude template="header.cfm"> in your index.cfm file and
在 header.cfm
中放入:
<cfparam name="url.professionalPaper" default="-1">
默认为 '-1' 表示在你的想法中“没有期望”会出现 9)。
你会有一个链接列表......你的链接列表将像这样构建:
<a href="?professionalPaper=0&paperID=1234">professionalPaper</a><br>
<a href="?professionalPaper=1&paperID=1111">something personalable and bloggie</a>
如果你想使用你当前所在的页面 index.cfm
你可以这样做:
<cfif structkeyExists(url,"paperID")>
Hi you are reading a paper...but which one?
<cfswitch expression="#url.professionalPaper#">
<cfcase value="0">
Yep we are a pro-paper just out the professional!
</cfcase>
<cfcase value="1">
This is a touchy feel blog post. I feel weepy.
</cfcase>
<cfdefaultcase>
Wait what? -1 in url.professionalPaper you need to pick 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>
这是基本前提...您可以根据需要对其进行更改。
如果您想将其指向一个捕获页面,例如:pages.cfm,然后更改您的链接。
<a href="pages.cfm?professionalPaper=0&paperID=1234">professionalPaper</a><br>
<a href="pages.cfm?professionalPaper=1&paperID=1111">something personalable and bloggie</a>
然后将其余逻辑填充到该页面中。这样您就可以在 index.cfm 中获得链接,在 pages.cfm
中获得您的页面逻辑。
那么你的 defaultcase 语句可以这样读:
<cfdefaultcase>
Wait what? -1 in url.professionalPaper you need to need to go back (link to go back to your index.cfm page of links).
</cfdefaultcase>
This is a high level treatment but I think you get the gist and I bet you can build on it too :)
关于html - 条件处理与单独页面——哪个有意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23761584/