Is there a list of variables available inside of a Page Attribute textarea?

Permalink
I'm interested to know if there is a way to output variables inside of a Page Attribute that would use a textarea editor.

I need to somehow pass the "BlockID" into the textarea of the custom attribute. I'm adding some tracking codes and we are appending them to the ajax response with javascript. They target the response div by using the blockID. Some pages on our site have multiple forms on the page so this makes sense for the blockID.

Is there a way to add the blockID into a Page Attribute textarea?

I had a variable like {path} that gets added in when i enter in the url into a block. Do more of these things exist?

 
JohntheFish replied on at Permalink Reply
JohntheFish
Do you mean a concrete5 page attribute of type textarea, or an attribute of an html textarea element?

If you mean the first, then you are probably going about solving this the wrong way.

If you mean the second, the $bID is available as a php variable in the block view.php.

In either case, beware that block ID is not a constant (it changes each time a block is edited) and is not unique (it is shared by copies of a block)
rfletcher replied on at Permalink Reply
Hi John,

Thank you for your reply!

I am new to concrete5 .. so working through it now...its quite different from wordpress.

I see that i can access $bID variable from any page using php.

I was referring to a Textarea under Page Attributes.

The reason i need to put the values in a textarea was to be able to add some tracking pixels. We are building landing pages and so each page will have its own unique tracking pixels. I wanted to add the one tracking pixel using a jquery .append, which i am doing but in a hard coded way. trying to update that so i can enter the tracking pixels via a field but i need to get that BlockID to append the tracking pixel to the response after the form is submitted.

I think i figured out a way to do this. I'm loading the attribute in a php variable and then doing a str_replace with php to add in the $bID.

I've tested and that seems to work. I was hoping that there were some predefined variables like for displaying random numbers and outputting pageIDs, blockIDs. Might be a good for a plugin.
JohntheFish replied on at Permalink Reply
JohntheFish
A page attribute is definitely the wrong way to go about what you are doing. Even if you get it to work, it will be a fragile mechanism and a maintenance nightmare.

It would be simplest to add your script either as an 'additional header' (per page) or through the same dashboard section as for a google tracking script (which is global). Other options for adding the script include as an asset in a package controller on_start/on_before_render event handler or in your theme.

The variable you need to track is the page id, already available in JavaScript as the global variable CCM_CID. If you look at any page in the developer console, you will see that in a script section near the top of the page.
rfletcher replied on at Permalink Reply
Thank you again John for helping me work through this.

I see how i might use the Addition Header to add my tracking codes. That may work out well. I don't understand the difference that field and creating a new textarea page attribute aside from it being global and also able to only show on a single page. Thats what i need. I need to be able to drop in custom tracking codes per page, so that sounds like it would work. The <noscript> code calls for a cachebusting value. I wasnt sure how to add that unless with the additional header i can put php inside of it and it parse on the page? Do you know if you can put php in there?

Also, we are using ajax to submit our form so i needed a way to append the tracking code after the form was submitted. I added a page attribute for that, but again i need a variable for the blockID so that i can target the response div that holds the message. I don't ccm_cid is what i am looking for because that just relates to the pageID, I am looking for the blockID which i don't think is availale via javascript. I suppose i could write some javascript and make it available to the application through a cookie or data attribute.

I'll look into package controller and assets, though I havent used them before. Do you think that will let me hook into variables and be able to add a custom thank you tracking pixel?

Thanks for your help!