evildan Posted March 13, 2002 Posted March 13, 2002 I'm looking for a way to use the value of a field as an include on an CDML page. Does anyone know if this is possible? I was thinking of trying this [fmp-include: [fmp-field:fieldname]] But I doubt that will work... should I put the entire include in the context of the field and simply put the field tag on the cdml page? [fmp-field: fieldname] (where the value id [fmp-include: theIncludeFile.html] If anyone knows this off the top of their head, I would really appreciate it. Thanks,
Garry Claridge Posted March 13, 2002 Posted March 13, 2002 You can use [FMP-IncludeField: fieldname ]. All the best. Garry
evildan Posted March 13, 2002 Author Posted March 13, 2002 nope that did work either... this raises an interesting question though... what does [fmp-includefield: fieldname] do? I know it's a replacement tag... Here's what the CDML Reference DB says... What it does [FMP-IncludeField] is replaced with the contents of a field, usually a text field that contains an HTML format file. Syntax [FMP-IncludeField: Fieldname ] Parameter(s) First parameter: Name of the field to include. Syntax example(s) Include a file using an HTML file [FMP-If: firstName .neq. "bob" ] [FMP-IncludeField: errorPage] [FMP-Else] [FMP-IncludeField: otherErrorPage] [/FMP-If] Does anyone have a syntax example that better fits this tag? I've tried [fmp-fieldinclude: fieldName] where "FieldName" = mypage.html AND the actual html raw code... it didn't work. I don't want to include the HTML raw code, becuase I could do that using this tag... [fmp:field: fieldName, raw] It seems this tag was created to include the NAME of the file to be included... am I right?
scratchmalogicalwax Posted March 13, 2002 Posted March 13, 2002 As Garry said you must always use curly brackets when nesting CDML tags! if that doesn't work......... When I produce web sites with Lasso I use [include: (Var: 'pagetemplate')] I dont set the variable from a field but you could adapt it to suit your needs (maybe using tokens instead of Variables) e.g. [if 'this'=='that'] [Var_Set: 'pagetemplate'='thispage.lasso' ] [Else] blah blah [/if] this allows me to build the page dynamically depending on what the user has chosen to do. obviously with CDML you use FMP-Include, FMP-If and use the curly brakets instead..... but do you have a version of Variable?:? or if you don't maybe you could use tokens instead and set these with the different page possibilities contained in the fields [ March 13, 2002, 01:46 PM: Message edited by: scratchmalogicalwax ]
evildan Posted March 13, 2002 Author Posted March 13, 2002 I could use tokens, but I don't want to use that approach becuase I think I'll be getting myself into the same problem. This site is a rebuild, so I am working under a format already created... the only option I that looked promising was nesting the value of a field into the include tag... and up until this morning that was the bases for my database and template development. [fmp-include: {field: fieldName}] didn't work... But is there a way to do this? I got side-tracked looking into [fmp-includefield: fieldName] which I am unable to varify what it actually does. The only option I appear to be left with is if I include the HTML source code in the field and use this tag.. [fmp-field: fieldName, raw] The only draw back to that is if I want to make a change to the html code that exists on more than one record, I have to change it on each of the corrisponding records as well. I could go so far as to create another database with just HTML code... and reference it using portals, but I really don't want to get into it that much. I was looking tor the option of simply editing one HTML file, and leaving all references to it unchanged. So if I edit "mypage.html" the 50 records that call for it by using the field as a point of reference don't have to be changed.
Garry Claridge Posted March 13, 2002 Posted March 13, 2002 The [FMP-IncludeField: fieldname] tag inserts html text from a field. Hence, the field could contain a whole page, including cdml tags; just like a format file. All the best. Garry
evildan Posted March 13, 2002 Author Posted March 13, 2002 My field could contain raw html and cdml tags? I've tried this and I get an error that it cannot read format file "fieldName" I have been unable to get [fmp-includefield: fieldName] to work at all.
Garry Claridge Posted March 13, 2002 Posted March 13, 2002 Here is another wild guess. The contents of your field could look like this: [FMP-Include: myformat.html] The master file like this: [FMP-IncludeField: myfield] This may be the way to nest includes. All the best. Garry
evildan Posted March 13, 2002 Author Posted March 13, 2002 yeah, I tried that approach... didn't work... value of field "myField"= [fmp-include: myfile.html] CDML tag on result page = [fmp-fieldinclude: myField] maybe I'm thinking of this all wrong. One html file, called by a CDML replacement tag based on the value of a field. I thought and still do think that [fmp-includeField: fieldname] should work... is this a FileMaker 5.5 only replacement tag? I'm using FileMaker 5.0 v.3 (that tag came is refered to in the 5.0 developer kit's CDML reference DB).
Keith M. Davie Posted March 14, 2002 Posted March 14, 2002 "this raises an interesting question though... what does [fmp-includefield: fieldname] do?" Essentially the same thing as the fmp-include. " [FMP-IncludeField] is replaced with the contents of a field, usually a text field that contains an HTML format file." I suppose there may be a reason to have a text field which is an html page in lieu of a format file which is used as an include. You seem determined to use an fmp-include. Okay. Forget the fmp-include:field. The examples (CDML Ref) suggest that you use the fmp-include in an if conditional on a format file such that, depending on the results of the comparative you can display one of two choices of format files. Okay. So you want to have a format file in which a field's contents are displayed but not modifiable. You use [fmp-field]. You may want to access other fields as text fields for input of new data or for editing. You make those using standard html/cdml. Okay. That becomes an include page. Call it whatever.htm. Okay. Now do you want another format file, say No Records Found, or another found set or whatever message or fields or db access you need. Create that format file. Okay. Now that becomes another include page. Call it somethingelse.htm. (Some sources recommend that you keep all includes in a folder "Includes" with you other format files. This is not necessary, though it may be helpful to you.) Okay, so now your format file from the search contains an fmp-if conditional such that one of those two include files will be displayed. [FMP-If: leftside .operator. rightside] [FMP-Include: whatever.htm] [FMP-Else] [FMP-Include: somethingelse.htm] [/FMP-If] That basically is how the fmp-include works. If you need more than two format file choices then you will need to use the fmp-elseif instead of the fmp-else and the appropriate number of /fmp-if's. In this way you can edit just the one format file for the 50 records. [ March 13, 2002, 05:16 PM: Message edited by: Keith M. Davie ]
Garry Claridge Posted March 14, 2002 Posted March 14, 2002 Have you tried the '-fmtfield' tag. This maybe a viable alternative. Good Luck. Garry
Keith M. Davie Posted March 14, 2002 Posted March 14, 2002 From www.filemaker.com. Support. Article:106856 CDML Tags Removed With Web Companion 5.0v4 Update The Web Companion released with FileMaker Pro 5 includes a number of new CDML tags and improvements to existing CDML tags. It was determined that three of these tags could create potential security risks, and were therefore removed with the Web Companion 5.0v4 update. The tags removed were: -fmtfield -mailfmtfield -errorfmtfield
evildan Posted March 14, 2002 Author Posted March 14, 2002 Well after some testing I have not produced a possitve result yet. Here's what I'm trying to do... I have a database that has one record for each page of a website I am developing. (It's a directory database used as a controller). When the client clicks on a link they are actually doing a search on the directory database. That database is trained to look to any of the other databases when it has to depending on the record it is called to return. The reason for this is method is that the client wants to have administration of the content and they don't want to see html raw code. (This is a firm request of the client). My intent is to still use HTML for the template file (of course) but also the files I don't want them editing... like the directory, header and footer portions of the page. The problem is that those files change depending on the directory the visitor is in (and if they are logged in or not). So I came up with the idea of creating a field that would contain the value of an html file I wanted to include... then on the template I could just insert a reference to the value of the field and have it include the associated file. I tried these two methods... -------#1---------- [fmp-inlcude: [fmp-filed:NamOfField]] That returned an include error "problems reading the file..." -------#2---------- [fmp-field: NameOfField] (AND) [fmp-field: NameOfField, raw] where the value of "NameOfField" would equal "[fmp-include: IncludeName.html]" This returned the value of the field. So no processing to the include occured. Is there a way to insert tag data into a field and have FileMaker proccess it as a CDML tag? before it composes the page? Am I looking at this problem the wrong way? I'd really like to figure this out, I can see a number of uses for it in some of the other sites I am planning on building.
evildan Posted March 14, 2002 Author Posted March 14, 2002 Thanks Garry, I tried it, but it didn't work. [FMP-IncludeField: fieldname ] And it returned an error: [Error reading format file: fieldname] where fieldname was = mypage.html
Garry Claridge Posted March 14, 2002 Posted March 14, 2002 I've been testing a site where most of the pages are fields in a database. However, you have the names of html files in the database. I guess that WebCompanion is doing one pass looking at the If tags, then another looking at Includes, and then a final pass looking at all other tags. I'm not sure if you can nest Includes; don't think so. Good Luck. Garry
Garry Claridge Posted March 14, 2002 Posted March 14, 2002 Try it with an Intra tag: [FMP-Include: {field:myfield}] Worth a go! Garry
evildan Posted March 14, 2002 Author Posted March 14, 2002 I think I'm going to end up using the [fmp-field: fieldName, raw] tag and having straight HTML in the field. I have not read the article, but I would guess that the [fmp-inlcudefield: fieldName] was removed in the update as well, I can't seem to get it to work at all and I have the update to the WebCompanion. I will take a look at a few other options but it seems that's my only option. Time is of course not on my side, so I may have to do some research and come back to the project with a better solution. Thanks everyone for all of your help, I really appreciate it.
evildan Posted March 14, 2002 Author Posted March 14, 2002 This may be the most drawn out solution to a simple problem but here's what I've done. I will try not to repeat anything I previously posted, but forgive me if I do. My problem has been solved by doing the following. I created the following database - mycode.fp5 - controller.fp5 controller.fp5 is a directory database. When a user clicks on a link they are actually doing a search for a directory in that database. mycode.fp5 contains a record for every html coded page. (the pages I want access to edit online but that the client will not have access to). The HTML code is pulled into "controller.fp5" via a series of portals. So with the creation of five portals and another database the problem is solved. I can opt to access the database with the html code and make those changes on the fly from any browser and leave the straight field information in the "controller.fp5" database to be edited via the client. Knowing the client as I do, this is the obvious answer. I know that in a month or so they are going to ask me if I can set the website up so they can edit the footer, header, and other aspects of the site. So I've created an entire site almost all of it is open source... and thus can be edited via a web browser. The beauty of the way this site was developed is that the aspects of the site that the client is going to change will be so simple, but it will offer them the ability to code their own site, if they wish to get more advanced in coding. I am very excited about how the site will turn out becuase I feel that this client's demands might require a skin change in the near future. The site could easily have the ability to change themes now. I would only have to create a new template file to show a different theme. And all of the aspects of the database would remain the same.
evildan Posted March 14, 2002 Author Posted March 14, 2002 Well I'm back to the drawing board.... The html tages I have in my HTML raw code won't work, along with the conditional CDML code... so that option is out. I'm back to looking tor a way to include one file based on the value of a record. I guess I'm going to have to plot out the options and use conditial [fmp-if: field: fieldName .eq. testPage][fmp-include: testpage.html][/fmp-if] I had myself kind of excited about the possibilty of editing the open HTML source with little effort on the back end. Oh well, I'll shelf the idea becuase it is taking me away from the progress of the site. So back to my orginal question... slightly modified... Is it possible to put a CDML replacement tag in a database and have that tagactually work when the recrod is called for? i.e. mydatabase.fp5 records inlcude: myField Value of myField = [fmp-inlcude: myfile.html] Master HTML/CDML page has the following [fmp-field: myField] but after processing it should include myfile.html where the myField tag was? [ March 14, 2002, 10:03 AM: Message edited by: evildan ]
scratchmalogicalwax Posted March 15, 2002 Posted March 15, 2002 I have to appologise for my useless post earlier I setup WC to run without Lasso and tried my suggestion and it didn't work! With Lasso something similar to what you want to do is possible with WC I'm not so sure. [ March 15, 2002, 03:54 AM: Message edited by: scratchmalogicalwax ]
simon1663 Posted September 27, 2002 Posted September 27, 2002 I guess this has been a while - but I just discovered that [FM-IncludeField] only works when the field to include is a global field. You can't use it with a regular data field or calculation field. Please correct me If I am wrong. But I want to use it too I guess if you still wanted to use format file from a regular field , then put a script which copies the content of the regular field into the global field. See -Script parameter for your CGI request.
simon1663 Posted September 27, 2002 Posted September 27, 2002 One other discovery, can't have IncludeField inside the InlineAction tags. However, Inclidefield can have InlineAction
Garry Claridge Posted September 27, 2002 Posted September 27, 2002 I think [FMP-IncludeField] was removed in version 5.5! Garry
Anatoli Posted September 27, 2002 Posted September 27, 2002 Somehow I still don't understand what is problem. What should be achieved?
simon1663 Posted September 28, 2002 Posted September 28, 2002 Garry, IncludeField works in both 5.5 as well as 6.0. I have tested in both places. I think it is one of the most useful tags for building dynamic pages programatically as opposed to relying on hardcore CDMLs. Since last night, I have already found dozens of use of it. At least one use of it has been protecting source code.
Garry Claridge Posted September 28, 2002 Posted September 28, 2002 Thanks. I confused it with -fmtfield Yes, I think that it has great potential for dynamic page building. All the best. Garry
Anatoli Posted September 29, 2002 Posted September 29, 2002 RE: At least one use of it has been protecting source code. In v. 6 is even better protection of code. Anyway, to fully protect code isn't possible. Just the CDML can be protected.
simon1663 Posted September 30, 2002 Posted September 30, 2002 What feature of Fm v.6 gives more control to protect code?
Garry Claridge Posted September 30, 2002 Posted September 30, 2002 You can prevent read access within the 'Web' directory. This means that all files will have to be processed by WebCompanion. Garry
Anatoli Posted September 30, 2002 Posted September 30, 2002 From FM 6 pdf: The easiest way to protect one or more CDML files in an existing solution is to copy the entire directory into the cdml_format_files folder and then delete the CDML format files from their original locations within the Web folder. HTH
simon1663 Posted September 30, 2002 Posted September 30, 2002 Thanx Anatoli, I was not aware of this feature. Seems a very cool decision from FM 6! Gotta go buy it now. Cheers
Anatoli Posted September 30, 2002 Posted September 30, 2002 Now, if they improve security of databases, we can be happy
simon1663 Posted October 1, 2002 Posted October 1, 2002 I was trying to build the format file on the fly using script. And then do the [FMP-IncludeField]. But it seems like Filemaker processes the format file hence the IncludeField even before the request is processed. Hence even though the field content changes during the process - The the old value is actually parsed. *******, this means I have to create redirect url for the user to come back for his contents..
Anatoli Posted October 1, 2002 Posted October 1, 2002 It is a bit of chicken and egg scenario. WC is not processing always after full display of FM calculation.
CyberSport Posted May 29, 2003 Posted May 29, 2003 DId you ever figure out an answer to this besides doing a redirect? (processing a replacement tag within an include tag) Are there any changes in 6 that allow us to do this, or is it always going to be the chicken/egg situation outlined by anatoli? Any solutions with inline that you can think of? thanks... Bevin
Recommended Posts
This topic is 7949 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now