Skip to content

Instantly share code, notes, and snippets.

@asika32764
Last active April 30, 2017 14:11
Show Gist options
  • Select an option

  • Save asika32764/811b3719c0b39a76b444 to your computer and use it in GitHub Desktop.

Select an option

Save asika32764/811b3719c0b39a76b444 to your computer and use it in GitHub Desktop.

View Setting

Note: the $data object in ApiView is Registry not Data object, we must use set() to set data.

Component is com_flower, view is sakuras.

// components/com_flower/view/sakuras/json.php

// ...

class FlowerViewSakurasJson extends \Windwalker\Api\View\ApiView
{
	// ...

	/**
	 * Prepare data hook.
	 *
	 * @return  void
	 */
	protected function prepareData()
	{
	    /** @var \Joomla\Registry\Registry $data */
		$data = $this->getData();

		$data->set('items', array('a', 'b', 'c'));
	}
}

How to Use

Add this view to menu.

Type http://your_site.com/flower/sakuras.json

Then you will see this json output:

{"success":true,"message":null,"messages":[],"data":{"items":["a","b","c"]}}
@biromain

Copy link
Copy Markdown

Can you disable profiler on json format when JDebug in on?

{"success":true,"message":null,"messages":[],"data":[]}<hr /><pre><h3>WindWalker Debug [namespace: Windwalker]: </h3>No Profiler data.</pre>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment