Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add new page: prepopulate fields from http get parameters
#1
For my I18N plugin I needed to call the edit page in a way that some meta data was prefilled.
In order to do this, I needed to patch the admin/edit.php:

Code:
...
if ($id)
{
  ...
}
else
{
  // --- add the following lines
  if (isset($_GET['parent'])) $parent = $_GET['parent'];
  if (isset($_GET['template'])) $template = $_GET['template'];
  if (isset($_GET['metak'])) $metak = $_GET['metak'];
  if (isset($_GET['metad'])) $metad = $_GET['metad'];
  if (isset($_GET['menu-enable'])) $menuStatus = $_GET['menu-enable'];
  if (isset($_GET['menu-order'])) $menuOrder = $_GET['menu-order'];
  if (isset($_GET['private'])) $private = $_GET['private'];
  if (isset($_GET['title'])) $title = $_GET['title'];
  if (isset($_GET['menu'])) $menu = $_GET['menu'];
  if (isset($_GET['newid'])) $url = $_GET['newid'];
  // --- add end
  $buttonname = $i18n['BTN_SAVEPAGE'];
}
...

It would be nice to include this in the next release to allow plugins to prepopulate fields to simplify the use of the CMS.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#2
I see what you are trying to do here, but why is your plugin creating a new page?
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Reply
#3
ccagle8 Wrote:I see what you are trying to do here, but why is your plugin creating a new page?

For the I18N plugin I have a page similar to the pages page, but with multiple columns, one for each language (e.g. first column is default language - en, 2nd is german - de, 3rd is french - fr). If there is e.g. no german page, the column will contain an add-link to add a page in this language, prepopulating:
  • title = title of default page + ' (de)'
  • slug = slug of default page + .'_de' (this is how the language is determined)
  • ...

Similarly, as each content in a CMS should be handled the same, a good news plugin should store news as normal pages (in order to be searchable by a search plugin, ...), this news plugin would create a prepopulated page, when the user clicks the "Add news" link:
  • slug = 'news_' + date (yyyyMMdd) + '_' + time (HHmm)
  • tags = '_news' (to identify news in a search plugin)
  • ...

Currently the only way to prepopulate the metadata for a page without patching GetSimple is to add javascript code during the 'edit-extras' trigger, which will then fill the fields appropriately (implemented in I18N plugin).
However this is quite ugly.

P.S.: I use this javascript to modify the parent and priority selects, too (best try the I18N plugin to see how a better parent and menu position management can look like).
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#4
mvlcek Wrote:P.S.: I use this javascript to modify the parent and priority selects, too (best try the I18N plugin to see how a better parent and menu position management can look like).

Bit of a threadjack, but can you break out the parent/child and menu code from the I18N code?

-Rob A>
Reply
#5
RobA Wrote:Bit of a threadjack, but can you break out the parent/child and menu code from the I18N code?

The parent/child and menu code is the main part of the plugin. The part supporting multiple languages is quite small, but mixed into the code - the menu needs to be displayed in the correct language.

However, you can use the plugin, even if you do not intend to have multiple languages on your site.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply




Users browsing this thread: 1 Guest(s)