?
Solved

prefex tags with Coldfusion

Posted on 2009-04-27
5
Medium Priority
?
250 Views
Last Modified: 2013-12-24
Hi i am using an application where somethings are defined using <cfimport tag to use to make things simple. but to me it created a problem:

here is the lines that troubles me:


<cfoutput>
	<tags:surveydisplay survey="#survey#" />
<cfelseif not structKeyExists(variables, "template")>
	<!--- Loads header --->
	<tags:layout templatename="main" title="Survey: #survey.name#">
	
		<tags:surveydisplay survey="#survey#"/>
			
	</tags:layout>
<cfelse>
	<tags:surveydisplay survey="#survey#" />
 
surveydisplay is the page where this is defined:
 
<cfparam name="attributes.survey">
<cfset surveyComplete = false>
<cfif not structKeyExists(session,"surveys")>
	<cfset session.surveys = structNew()>
</cfif>
 
for the above i just removed the cfimport tag and tried something this:
 
<cfinclude template="surveydisplay.cfm">
 
but it give this error:
 
he following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request
The required parameter ATTRIBUTES.SURVEY was not provided.
This page uses the cfparam tag to declare the parameter ATTRIBUTES.SURVEY as required for this template. The parameter is not available. Ensure that you have passed or initialized the parameter correctly. To set a default value for the parameter, use the default attribute of the cfparam tag.
 
The error occurred in C:\Inetpub\wwwroot\surveydisplay.cfm: line 1
 
1 : <cfsetting enablecfoutputonly=true>
2 : <cfdump var="#session#">
3 : <cfparam name="attributes.survey">

Open in new window

0
Comment
  • 3
  • 2
5 Comments
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24244622
it looks like surveydisplay and layout are custom tags used by your application.
you can't just <cfinclude> them.

what exactly is the problem you are having? you have not really explained it...

Azadi
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 24244894
yes they are really custom tags:

my just cfinclude cannot work here.

Ok:

first i start with the layout Tag:

Here below its code:

after that it is calling the surveydisplay tag like this:

<cfinvoke component="admin.cfc.auth" method="getSurvey" id="#trim(url.id)#" returnvariable="survey"/>
    <cfif survey.active IS 1 or survey.showThis EQ 'Yes'>
    <cfdump var="#survey#"><cfabort>i dumped it and i get query results: as:

the file is attached.

now this below thing is calling the surveydisplay which have a record:
<
tags:layout
 
templatename
=
"main"
 
title
=
"Survey: #survey.name#"
>

        
                
<
tags:surveydisplay
 
survey
=
"#survey#"
/>

                        
        
</
tags:layout
>


<
cfelse
>

        
<
tags:surveydisplay
 
survey
=
"#survey#"
 
/>


surveydisplay page is something like this:

<cfparam name="attributes.survey">
<cfset surveyComplete = false>

<!--- Initialize in session scope if it doesn't exist --->
<cfif not structKeyExists(session,"surveys")>
	<cfset session.surveys = structNew()>
</cfif>

<!--- Initialize certain values in the session struct --->
<cfif not structKeyExists(session.surveys,attributes.survey.id)>
	<cfset session.surveys[attributes.survey.id] = structNew()>
	<cfset session.surveys[attributes.survey.id].currentStep = 1>
	<cfset session.surveys[attributes.survey.id].answers = arrayNew(1)>
	<cfset session.surveys[attributes.survey.id].maxQuestions = application.question.getQuestions(attributes.survey.id).recordCount>
</cfif>

Open in new window

So i am here how removal of tags: custom tags to make the page simple will work though

<cfif isDefined("attributes.templatename")>
	<cfset attributes.template = attributes.templatename>
</cfif>
<cfparam name="attributes.template">
<cfparam name="attributes.title" default="">
<cfparam name="attributes.loadspry" default="false">
 
<cfset base = "../pagetemplates/" & attributes.template>
 
<cfif thisTag.executionMode is "start">
	<cfset myFile = base & "_header.cfm">
<cfelse>
	<cfset myFile = base & "_footer.cfm">
</cfif>
 
<cfinclude template="#myFile#">
 
<cfsetting enablecfoutputonly=false>

Open in new window

www.bmp
0
 
LVL 27

Accepted Solution

by:
azadisaryev earned 2000 total points
ID: 24247042
well, again, what IS the problem?

did the custom tags stop working? do they output wrong data?
why do you so much desire to change it if it works fine?

custom tags (ct) are a great tool in cf - you should learn them if you are not very familiar. they are great for code re-use and modularization of code. ct are akin to functions/udf, but have a lot of advantages over them.

the 2 custom tags in your application are:

1) layout - it seems to just insert header and footer templates into pages where it is used.
it is probably called twice in every page: once for the header (opening tag) and once for the footer (closing tag). it also has a loadspry switch - but from your posted code i can't fathom what exactly that switch does...

if you get rid of this ct, you will have to instead put 2 <cfinclude>s into every page of your site where this ct was used to include the header and footer pages.

why a ct is better for this job than <cfinclude>? well, if, for example, the base path to headers/footers folder changes on your website, you will only need to edit the path in one file - the custom tag - instead of changing 2 <cfinclude>s in every page of your site.

2) surveydisplay - judging by the code you posted, it seems to build some sort of survey questionnaire, storing survey data and answers in session scope, and probably controls the display of questions of the survey as well...

hope this helps!

Azadi
0
 
LVL 16

Author Closing Comment

by:Gurpreet Singh Randhawa
ID: 31575121
Anyways, This is not a solution but here one thing i understood that Custom tags have some value which play an important role
0
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24247557
@myselfrandhawa:

if you have actually stated your problem, we might have provided detailed help.
but the way your 'questions' were phrased, i failed to understand what your actual problem was... i have even asked twice in my replies for you to clarify this.

please do not take this as a rant or a negative comment towards you - i am just trying explain why it was impossible to provide a solution to your 'problem' and to help you get better expert help and solutions in the future.

phrases like "here is the lines that troubles me" and "" are very moot do not describe a problem in any way that can help us to help you.
try to be as specific as you can when describing a problem:
explain what the code does and how it is different what you expected it to do;
copy and paste exact cf errors you get, if any;
state your questions as questions: "What does <cfimport> tag do in my attached code, why do i need it there and what do i need to change in my code if i want to remove it?" is a question, "am using an application where somethings are defined using <cfimport tag to use to make things simple. but to me it created a problem" is NOT;
when posting code, try and make it as 'executable' as possible - so a test case of your problem can easily be re-created by experts who are trying to help you out; at the very least, make sure the code is structurally correct (no missing opening/closing cf tags, any referenced UDFs/CFCs are posted as well, comment code lines where necessary) and does not include irrelevant html/styling.

once again, this open discussion post is aimed to help you get better help with your problems next time. hope you understand!

cheers,

Azadi
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question