include with a querystring

Discussion in 'Classic ASP' started by bluebeard96, Aug 6, 2006.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hello, I've searched around and not found exactly what I'm looking for. I understand how to do a dynamic include using a querystring, but I want to include a file that HAS a querystring.

    For example, I'm working on a site for a plastic card printer. I want to have a file name of "plastic-hotel-key-cards.asp". There are numberous types of cards he can do (gift cards, library cards, gaming cards, etc) and each type has it's own page.

    I want all the card pages to have a similar template, so I was thinking I would create a page named "plastic-card-types.asp" and add on a querystring like "?type=hotel" or "?type=gaming". Inside this page, I would have a select case statement, and assign value to various sections of the page ("headline = 'Plastic Hotel Key Cards'", and sample_image_src='sample-hotel-key-card.jpg", etc). Then I woulddisplay one layout, calling in the variable content that wasset in the select statement, as follows:

    <div class="headline"><%=headline%></div> and so forth

    So, basically when somebody clicks on "plastic-hotel-key-cards.asp" thay are given the content of "plastic-card-types.asp?type=hotel"

    The problem is, I can't do "<!--#include file='plastic-card-types.asp?type=hotel'-->. If I pull off the querystring it'll show just find, but I need the querystring to show the dynamic content. I want to do this withour a redirect, as I want the page adress for search engines to be plastic-hotel-key-cards.asp

    Any ideas how I can accomplish this? There's probably a simple solution I'm looking right past! Thanks in advance!

    Mike Reilly
     
  2. Ok, you can't include with a querystring because your not calling a URL when you include thatfile, your physically opening thefile and including it in your script before it executes. Plus You would likely run into issues trying to include a script inside itself.

    The easiest solution would be to use the Else statement in your Querystring to set the variables to the same values as you did for the 'hotel' case. Example:
     
  3. Yeah, but in that example, the "calling" page would have to have a querystring, correct (ie plastic-hotel-key-cards.asp?type=hotel)? Along that line, however, maybe I could just do my select statement based on the page name/URL, not a querystring value. I could just do a regular include to "plastic-card-types.inc". Inside that file I have a select statement that will assign variable values based on page name, and have the display "template" inside that file as well.


    So, plastic-hotel-key-cards.asp simply has inside it



    <!--#include file="plastic-card-types.inc"--></BLOCKQUOTE>
    And the plastic-card-types.inc file looks something like this:

    SelectCaseRequest.ServerVariables("URL")
    Case"/plastic-hotel-key-cards.asp"
    headline="PlasticHotelKeyCards"
    sample_img_src="sample-hotel-key-card.jpg"
    Case"/plastic-gaming-casino-cards.asp"
    headline="PlasticGaming/CasinoCards"
    sample_img_src="sample-gaming-casino-card.jpg"
    CaseElse
    'ifnomatchthedisplayhotel
    headline="PlasticHotelKeyCards"
    sample_img_src="sample-hotel-key-card.jpg"
    EndSelect
    'Display Template
    ......</BLOCKQUOTE>


    That should work. Another option isto use a component I haven't used before... ASPTear. I'm assuming I can place the Tear code inside my "plastic-hotel-key-cards.asp" page, have it Tear "plastic-card-types.asp?type=hotel", and display the result. I don't know how much more time/processing power is used in tearing though. Would it cause a problem with a lot of traffic?


    I think the first solution is better though. Thanks Tarwn for pointing me in the right direction. Simple solution, but my brain was stuck in another line of thinking. :)


    Mike
     
  4. The Else statement in the select I posted takes care of the page being posted without a Querystring. You would just execute the same code in the Else as you do in the 'Hotel' option. To the end user it would appear exactly the same whether they came in with a querystring ?type=hotel or came in with a bare URL.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page