Jump to content

How to render runtime markup (=custom PHP snippet) in page edit interface?


valan
 Share

Recommended Posts

Q: see topic title

As far as I understand there should be at least two ways:

- kind of locked Textarea/CKEdit field that is filled with markup being generated from PHP snippet when page is opened in edit mode

- some kind of hook that injects markup into the edited page in right place

I've checked available modules but haven't found the answer. If this kind of Q has been addressed somewhere before, I would be glad to hear about it!

Link to comment
Share on other sites

i usually use a custom module and put all of my custom admin stuff there, e.g.:

public function ready(){
	if($this->page->process == "ProcessPageEdit"){
		$this->addHookAfter('ProcessPageEdit::buildFormContent', $this, 'mySpecialThing');
	}
}

public function mySpecialThing(HookEvent $event) {
		$form = $event->return;
		$field = $this->modules->get("InputfieldMarkup");	
		$field->markupText = "<h3>My Special Thing</h3>";
		$form->prepend($field);				

	} // end function

  • Like 4
Link to comment
Share on other sites

it depends a lot what the content will be;

if it is static info, then i would use textarea markup module

if it is something that needs to be dynamic, using javascript/ajax, then i might use the textarea markup but have some custom admin jquery that can read other values/fields and change the content of the text area.

for php generated stuff i don't know how to insert it between other fields, using the module code, but there might be a way... you could always put it at the top and then move it with jQuery

  • Like 1
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...