HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Custom Comcode problems

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#76218 (In Topic #15731)
Avatar

Well-settled

It seems obvious but code is winning

I am attempting to do a custom comcode tag to include a google map in a catalog field. It seems obvious what I need to do but it is not doing what I want. Specifically, the HTML (with < converted to < and such) is being displayed instead of the map. Clearly I am missing something obvious.

While I have more in mind for the tag, the most basic is to just paste the Google embed HTML into the tag. Something like this:

Code

[gmap]google_magic_code[/gmap]

It would then seem I would define the tag like this (for the most trivial case)

Code

[html]{content}[/html]

Unfortunately the end result is that the HTML from Google is displayed (with the HTML tags escaped).

What am I missing?
Back to the top
 
Posted
Rating:
#76221
Avatar

Could be a bug, what's the catalogue field type?


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#76222
Avatar

Well-settled

A Block of translatable/Comcode text. (I had originally used just a line but the Google code is too big).
Back to the top
 
Posted
Rating:
#76233
Avatar

Community saint

Hi felipe,

When you use custom comcode tags you should place the html in the comcode tag's "Replacement text" field and not in your Parameters.

So instead of using:

Code

[gmap]google_magic_code[/gmap]
you would use:

Code

[gmap][/gmap]

And in the comcode tag's "Replacement text" field you would have:

Code

google_magic_code

This also means that you should use a field type of "A brief line of translatable/Comcode text".

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#76241
Avatar

^ he's right


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#76242
Avatar

Well-settled

Yes, but, … Let me first make sure I follow this as my expression "google's magic code" may have been misleading. It is not code as in Javascript or anything that is to be executed in the browser. Here is a shortened version of what it is like. (It comes from going to google maps and selecting the embed code.)

Code



While some of it is boilerplace, there are multiple parameters that are not. ll, spn and z are examples.

I realize I could define the tag with the boilerplace and then pass the ll, spn and z parameters to it (and may actually do a variation of this as I am thinking I do want some changes) but I am still confused as to what I was doing did not work/is "wrong" for some value of wrong. That is, why the HTML < got converted to

Code

&lt;
 even though the Comcode definition was, more or less,

Code

[html]{content}[/html]

Just to beat the horse (OK, tofu, I'm vegetarian) to death, I am thinking the "correct" way to do this would be to just pass the string following src= to the Comcode tag and include the iframe boilerplace within the Comcode tag definition. Is that correct?
Back to the top
 
Posted
Rating:
#76243
Avatar

Yes almost certainly the Comcode parser will be considering it has to 'escape' the 'contents' of the tag which is where you were putting your HTML.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#76244
Avatar

Well-settled

OK, I understand what is happening but I thought that was what the

Code

[html]
surrounding it would prevent. I understand why (it is during parsing and not during substitution) but it seems easy (particularly for someone "off the street" that doesn't know what a parser is, to miss the distinction. Or, in my case, I just expected text replacement substitution first and then the result to be parsed.

That doesn't make the way it works as wrong but it probably should be explained in the tutorial.
Back to the top
 
Posted
Rating:
#76247
Avatar

Feel free to explain on community docs :).


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#76248
Avatar

Well-settled

OK, once I actually get this figured out I will do that. I understand this discussion but Google is not happy. Their iframe code works directly but I am somehow breaking it when I try to break out the boilerplate and put it in the tag definition.

I will solve this. Thanks for the help.
Back to the top
 
Posted
Rating:
#76249
Avatar

Community saint

felipe said

I am thinking the "correct" way to do this would be to just pass the string following src= to the Comcode tag and include the iframe boilerplace within the Comcode tag definition. Is that correct?
Technically that would not be the correct way because src itself contains multiple paramaters, but from a "simple for the user" point of view it should be fine to do so providing that the &amp; escaping in src does not cause problems.

felipe said

but I thought that was what the

Code

[html]
surrounding it would prevent.
It does, when {content} is a direct input, but in your case {content} is coming via a field, and it is being escaped by the field before it reaches your html tag.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#76250
Avatar

Well-settled

OK, you confused me again and I think this confusing is the reason I am now fighting with Google. What exactly to you mean "by a field"? It is clear the Comcode tag needs some sort of passed data. How would you pass it without it getting parsed before substitution?
Back to the top
 
Posted
Rating:
#76252
Avatar

Community saint

felipe said

OK, you confused me again
Sorry about that felipe  :( .
What exactly to you mean "by a field"?
just your "catalog field".

It is clear the Comcode tag needs some sort of passed data.
If I have:

Code

[html]some <b>bold</b> text[/html]
Then I have entered Some…text directly into the html tag. But if I have:

Code

[html]{content}[/html]
Then I have not entered anything directly into the html tag, but am expecting {content} to come later.
the reason I am now fighting with Google.
I suspect the reason is because the &amp;'s are getting escaped.

Lets say you have the following google maps src:

Code

[gmap]http://maps.google.com/?ie=UTF8&amp;ll=37.0625,-95.677068&amp;spn=60.54737,135.263672&amp;t=m&amp;z=4&amp;vpsrc=1&amp;output=embed[/gmap]
What actually reaches your custom comcode tag will be:

Code

[gmap]http://maps.google.com/?ie=UTF8&amp;amp;ll=37.0625,-95.677068&amp;amp;spn=60.54737,135.263672&amp;amp;t=m&amp;amp;z=4&amp;amp;vpsrc=1&amp;amp;output=embed[/gmap]
You pass that on to google and google will not like it.

So if you want to pass just a src you will need to manually unescape the src you got from google, which would look like this:

Code

[gmap]http://maps.google.com/?ie=UTF8&ll=37.0625,-95.677068&spn=60.54737,135.263672&t=m&z=4&vpsrc=1&output=embed[/gmap]
Also note that what you do for src you will also have to do for href, so your custom comcode tage should look something like this:

Code

<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="{content}"></iframe><br /><small><a href="{content}" style="color:#0000FF;text-align:left">View Larger Map</a></small>
Notice how {content} is used twice.

Hope this has cleared thing up.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#76253
Avatar

Well-settled

OK, got it. And I have actually decided to go with multiple passed parameters rather than having all this strange stuff being substituted each time.

That said, another "gotcha" was that I had assumed that the Comcode tag was evaluated when you accessed a page that used it. Apparently a bad assumption–it is really substitution that takes place when you enter the data. This was an issue because when I was trying to figure stuff out I would change the Comcode tag definition and had assumed it would change the execution-time result of entries already in the catalog.

Back to the top
 
Posted
Rating:
#76254
Avatar

That's a good point, worth again adding to community docs  :lol:


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#76255
Avatar

Regarding your original point about nesting HTML inside a tag, I think maybe you just needed to check 'Textual tag'. It is this that turns on Comcode evaluation of the contents, otherwise it is considered a literal value (i.e. not markup) and escaped accordingly.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#76256
Avatar

Added this to next version of docs:
"Note that Comcode is cached, and if you edit a tag after adding Comcode using it, it won't be updated until you edit that content (or the Comcode field precalculation cache is emptied)."

And clarified meaning of "Textual tag" Custom Comcode tag param.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#76257
Avatar

Well-settled

This is good stuff – what I needed to hear up front. Note that in a past life I was a software tester and these days if I just try to used 99.99% solid software, I will automatically gravitate to where there is a problem. Good skill but not when you just want to use something.
Back to the top
 
Posted
Rating:
#76258
Avatar

Always looking to resolve such problems, not enough people are vocal about the processes they go through and little issues they find.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#76278
Avatar

Community saint

felipe said

OK, got it.
Great!.
And I have actually decided to go with multiple passed parameters rather than having all this strange stuff being substituted each time.
Even greater :thumbs: .
Note that in a past life I was a software tester and these days if I just try to used 99.99% solid software, I will automatically gravitate to where there is a problem. Good skill but not when you just want to use something.
Same here felipe. I've found that I actually have to restrain my self from reporting everything I see otherwise it feels like I'm at work.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: