Jump to content

Using hanna to output js/php


louisstephens
 Share

Recommended Posts

I have a repeater with a text field where I would like to use hanna code (to make it easier on the user) so the user can define the action of a image that is in the repeater. For example:

1. The image should have an external link:

- the user can just type in the url

2. The image, when clicked, should be printable (using print.js)

- the user can just type [[print_image]]

That works just fine, but I am running into an "issue". The code I need to use to print is:

onclick="printJS({printable: 'path_to_image', type: 'image'});"

I can put that into the hanna code as plain text, but I have no idea how to get the image from the repeater item and pass to "path_to_image". Is this even possible?

Link to comment
Share on other sites

25 minutes ago, louisstephens said:

I have a repeater with a text field where I would like to use hanna code (to make it easier on the user) so the user can define the action of a image that is in the repeater. For example:

1. The image should have an external link:

- the user can just type in the url

2. The image, when clicked, should be printable (using print.js)

- the user can just type [[print_image]]

That works just fine, but I am running into an "issue". The code I need to use to print is:


onclick="printJS({printable: 'path_to_image', type: 'image'});"

I can put that into the hanna code as plain text, but I have no idea how to get the image from the repeater item and pass to "path_to_image". Is this even possible?

Yes, this should be doable!

https://github.com/ryancramerdesign/ProcessHannaCode (Check PHP Usage Notes)

If I understand the docs correctly, the $page variable context will be the repeater page where the image field is. 

Link to comment
Share on other sites

Thanks elabx. I might need a bit more help here. I currently have [[print_image]]:

onclick="printJS({printable: 'path_to_image', type: 'image'});"

But I also need "path_to_image" filled out, but I wasnt sure how to echo the php inside of a hanna code that was set to "text/html". Perhaps I am making this more difficult than it needs to be, but I was trying to work around using if statements in my actual template to check whether the user typed a url vs the shortcode.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...