Jump to content

Recommended Posts

Posted

I have in mind to use the profile data from the currently logged in shopper to send via querystring to a third-party feedback form.

So, in the file \skins\-myskin-\styleTemplates\content\profile.tpl where the parser replaces {VAL_LAST_NAME} with the appropriate data from the currently logged-in visitor (for this particular session), can I also use this in a link in any of the Site Docs?

When I think about it, it seems like it would not work, because a site doc is read out of a database record and is probably NOT parsed. Is there a owner/programmer-callable function call that will parse these placeholders?

I know there are "Contact Us" mods available, but since I already have one, and I'm willing to experiment to transfer data in this manner, maybe someone can drop a few hints on where to get started.

Posted

I found in \includes\content\viewDoc.inc.php where the replacement process takes place. Now I need to figure out how to recurse $view_doc.

Do I need to create a new XTemplate? How long does an XTemplate persist?

I'm hoping ccUserData[x][y] is globally valid across all pages once logged in.

Posted

An XTemplate is a file with .tpl extension, as you can see by reading the includes files. Also, you can see in CubeCart, that the XTemplate files consist of XHTML which contain two unusual elements . . .

1. Parsing cues that look like html commnets <!-- BEGIN: some_name --> <!-- END: some_name -->

2. Placeholders for generated content, {SOME_NAME}

The parsing cues correspond to code similar to this in includes files:

$view_doc->parse("view_doc.someName");

And the placeholders are assigned like this:

$view_doc->assign("SOME_NAME","This text is assigned to placeholder");

Posted

Good info about what the parse() function is working on. Where is that function?

The question I was really asking was, is the assign() function sequential or batched? That is (forgive the bad PHP coding):

// Global variables persist across session

var2 = " {GLOBAL3} Day";

var3 = "My";

// Local variables for this page only

var1 = "Make{GLOBAL2}";

outString = "{VAR1}";

$outString->assign("VAR1",$var1)

// So now outString should contain "Make{GLOBAL2}"

// If I were to do this:

$outString->assign("GLOBAL2",$var2);

// $outString should now contain "Make {GLOBAL3} Day"

// Next:

$outString->assign("GLOBAL3",$var3);

// I should have "Make My Day"

But I don't when I worked on the following experiment.

I put {VAL_LAST_NAME} in one of my site docs, then copied the code from the profile.inc.php that replaces {VAL_LAST_NAME} with the data from the database record. The {VAL_LAST_NAME} was still visible in the site doc. Assign() did not replace it. And I'm sure I coded it correctly.

The question is, as seen in the code above, can these placeholders be 'nested'?

Posted

Well, I am quite the nubian amateur and don't really read the code all that well. I don't know about nesting placeholders, sounds a little strange, but of course you may concatenate the contents assigned to placeholders and for the most part you are looking at different ways of dealing with nested arrays here.

In answer to the concrete question, "Where is the parse function?" look for the functions of the XTemplate system in classes/xtpl.php

Posted

OK, I've examined the XTemplate class and made a cursory look through the parse() function.

More importantly, I looked at the assign() function and now I see that this function is not making any text substitution when called, but rather using the placeholder as an index entry in an array and giving the text supplied as the value in the array at that index.

Then it's all parsed. Which means, it's batched. That is, the illustrative code earlier would end up with:

vars["VAR1"] = "Make{GLOBAL2}"

vars["GLOBAL2"] = " {GLOBAL3} Day"

vars["GLOBAL3"] = "My"

and when parsed (I believe), would result in:

outString = "Make{GLOBAL2} {GLOBAL3} DayMy"

My next experiment is to run the outString through another iteration of assign() after the parse() function.

Posted

Well, text() can save the result to a variable. The problem then becomes how to reintroduce the contents of that variable back into Xtemplate for another go around.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...