benjancewicz Posted June 13, 2007 Share Posted June 13, 2007 So... I think that ASP can do this, but I'm not sure.If I have an include that's pulled onto the page, is there something that I can write into the include so only a section of it shows up?I think what I do is this:The Include: <% SUB section1 %>Item 1Item 2Item 3<% END SUB %>Item 4Item 5 The parent page pulling the include: <% section1 %><!-- #INCLUDE FILE="includes/section1.asp" --> The end result would be a parent page that only displays:Item 1Item 2Item 3Am I right? Link to comment Share on other sites More sharing options...
zppblood Posted June 13, 2007 Share Posted June 13, 2007 Not an ASP guy, but I'm pretty sure it would returnItem 4Item 5Unless you used something like "Call section1", and that should include the other 3.An examplehttp://w3schools.com/asp/asp_procedures.asp Link to comment Share on other sites More sharing options...
justsomeguy Posted June 13, 2007 Share Posted June 13, 2007 You can do it two ways. Either you can put functions in the include file, include it and call the functions, or have variables as flags where you define the variables first, then do the include. This is the first way, with functions:include file: <%function part1()%>item 1item 2item 3 <%end functionfunction other()%>item 4item 5<%end function%> The file that does the including would need to use function calls to display everything: <!-- #INCLUDE FILE="includes/section1.asp" --><%part1()other()%> This way, you would have to enclose everything inside functions, anything not in a function would be displayed immediately, and before anything that is inside a function. If you have some content that you might want to show, and other content that you always want to show, the second method is probably the best. Your include file would look like this: <%if show_part1 = true then%>item 1item 2 item 3<%end ifif show_part2 = true then%>item 4 item 5<%end if%>always show thisitem 6item 7 The main file would look like this: <%Dim show_part1, show_part2show_part1 = trueshow_part2 = false%><!-- #INCLUDE FILE="includes/section1.asp" --> Link to comment Share on other sites More sharing options...
benjancewicz Posted June 25, 2007 Author Share Posted June 25, 2007 This is perfect!This is how I implemented it (I used the first example).On this page there is an "Events" section: https://www.fatherhood.org/Christian/That page only displays the latest event, which includes a link to "View past events."It links to a page that displays ALL the events: https://www.fatherhood.org/Christian/eventsfull.aspThanks for your help! This will change the way I design. :)Just out of curiosity (I can ask the other forum if you don't know), is there a way to do this with PHP too? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 25, 2007 Share Posted June 25, 2007 You can do the same thing in PHP, the syntax is just different. Link to comment Share on other sites More sharing options...
benjancewicz Posted June 26, 2007 Author Share Posted June 26, 2007 Would you know what that would be? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 26, 2007 Share Posted June 26, 2007 This is the syntax to create functions in PHP: <?phpfunction part1(){?>item 1item 2item 3 <?php}function other(){?>item 4item 5<?php}?> Link to comment Share on other sites More sharing options...
benjancewicz Posted June 26, 2007 Author Share Posted June 26, 2007 Wonderful. Thank you so much!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.