Skip to content

Instantly share code, notes, and snippets.

@Paladin
Created June 1, 2014 00:03
Show Gist options
  • Save Paladin/d3c53b8e677e36d67baa to your computer and use it in GitHub Desktop.
Save Paladin/d3c53b8e677e36d67baa to your computer and use it in GitHub Desktop.
There has to be a better way!
default.xml:
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_PGN_GAME_VIEW_DEFAULT_TITLE">
<message>
<![CDATA[COM_PGN_GAME_VIEW_DEFAULT_DESC]]>
</message>
</layout>
<fields name="request">
<fieldset name="request">
<field
name="title"
type="sql"
query="SELECT id, title FROM #__pgn"
key_field="id"
label="COM_PGN_GAME_FIELD_SELECT_LABEL"
description="COM_PGN_GAME_FIELD_SELECT_DESC"
extension="com_pgn"
required="true"
default="0">
</field>
</fieldset>
</fields>
</metadata>
Results in the control I want in selecting a menu item (option name is the text from title, while option value is the id of the record).
But I had to whack the getItem call in the model:
public function getItem($pk=null)
{
$app = JFactory::getApplication('site');
$id = $app->input->getInt('id');
if(!$id) {
$id = $app->input->getInt('title');
}
.
.
}
to allow both the game tables and the menu item to work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment