Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

cfloop / cfquery cf_tag "only for experts"

Posted on 2006-05-03
7
Medium Priority
?
355 Views
Last Modified: 2013-12-24
Hi there,

This is my question:

I am creating a CF_TAG wich i can use to display an amount of articles on specific page.
----------------------------------------------------------------------------------------------------------
This is my cf_tag:  <cf_article view="2" status="1" zone="100" max_articles="5">
                            VIEW is public (2) or not public (1)
                            STATUS is online (1) or offline (2)
                            ZONE is page where i place articles
                            MAX_ARTICLES is amount of articles i wish to display

Then i create a list of attributes:
----------------------------------------------------------------------------------------------------------
<cfparam name="Attributes.view" default="1,2">
<cfparam name="Attributes.max_articles" default="1">
<cfparam name="Attributes.zone" default="0">
<cfparam name="Attributes.status" default="1,2">

Then i create my query:
----------------------------------------------------------------------------------------------------------
<cfloop index="createArt" from="1" to="#attributes.max_articles#">
   <cfquery name="getArticles" datasource="database">
   select * from articles
   where article ... (here i am already stuck, tried a dozens options)
   </cfquery>
</cfloop>

Problem is: that it is possible that an article can be in a view (1) and in the database be 1,2...

And here I would need to have an output (i've got already the DESIGN for my table-output)... just need the <cfloop or cfoutput tags...
0
Comment
Question by:kosmozzed
  • 3
  • 2
6 Comments
 

Author Comment

by:kosmozzed
ID: 16596911
This is my query:

<cfquery name="getArticle" datasource="#database_src#">
            SELECT      *
            FROM         dbo.articles
            WHERE        <cfif #attributes.status# NEQ "">(dbo.articles.articleStatus = '#attributes.status#')<cfelse>
            dbo.articles.articleStatus IN ('#attributes.status#')
            </cfif>
            <cfif #attributes.zone# NEQ "0">AND (dbo.articles.articleZone = '#attributes.zone#')</cfif>
            <cfif #attributes.view# NEQ "0" AND #ListLen(attributes.view, ',')# EQ 1>AND (dbo.articles.articleView = '#attributes.view#')
            <cfelseif #attributes.view# NEQ "0" AND #ListLen(attributes.view, ',')# GT 1>AND dbo.articles.articleView IN ('#attributes.view#')
<cfelse><cfthrow message="bad query"></cfif>
      </cfquery>

He doesn't look into a result where the view-result is (1,2)...
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 16598413
First of all I don't know why you labeled the subject "only for experts"  since looking at your code there are many things even some beginners may be able to point out as not very good coding.  For example you have # in <cfif ...> tags when it is inefficient to do so and not needed.  Also you do not use <cfqueryparam, which makes you vulnerable to dangerous SQL injection attacks.


However, regarding your question - I am totally confused.

How can you have "STATUS is online (1) or offline (2)" and then have the default be "1,2"

It is both on and offline?  You are going to need to explain better what you are after here...
0
 

Author Comment

by:kosmozzed
ID: 16603172
Getting a result if the status is public or offline is no problem at all.  Getting a result when the status is public and also offline is the point.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
LVL 35

Expert Comment

by:mrichmon
ID: 16606770
But according to your definition status is NEVER public.  The view is public.
0
 

Author Comment

by:kosmozzed
ID: 16625035
status can be both public as well as never public...
0
 
LVL 12

Accepted Solution

by:
mmc98dl1 earned 1000 total points
ID: 16635529
How about you just assume everything is not public, and if view = 1 then its also public. Then in your database you only need to store 1 or 0. Then you query for internal pages doesnt specify view and for a public pages goes for view = 1.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

810 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