View Full Version : Create Custom Phrase Types
evenmonkeys
07-16-2005, 01:43 AM
I'd like to be able to add my own phrase groups... Could someone please come up with something that would make this possible? Adding it in manually via phpMyAdmin doesn't work. Gives errors in the admincp.
Please & thank you.
Andreas
07-16-2005, 01:49 AM
It does work, if you are executing the correct queries :)
Take a look at add_phrase_type() in includes/adminfunctions_language.php.
Unfortunetely there is no GUI to add Phrase Types. There was a Hack for vB 3.0.X to do so, but AFAIK it has not been ported yet.
evenmonkeys
07-16-2005, 01:52 AM
Well, I mean just entering it in directly to the rows. Not through queries or anything. I just inserted a new row. Didn't work. I also tried changing one of the rows that said reserved. Didn't work. >_<;
Andreas
07-16-2005, 01:54 AM
As said, you must use the apropriate Queries.
Take a look at the function I mentioned.
evenmonkeys
07-16-2005, 01:59 AM
Well, I don't know what any of that means... so that means someone needs to make something for me to use. =D
Andreas
07-16-2005, 02:01 AM
This is most likely not gonna happen (too soon) ;)
So if you want custom Phrase Types, you'll have to look at the code.
Adrian Schneider
07-16-2005, 02:51 AM
newfilename.php
<?php
require_once("./global.php");
// ################################################## ###########################
// function to allow modifications to add a phrasetype easily
function add_phrase_type($phrasegroup_name, $phrasegroup_title)
{
global $DB_site;
// first lets check if it exists
if ($check = $DB_site->query_first("SELECT * FROM " . TABLE_PREFIX . "phrasetype WHERE fieldname = '$phrasegroup_name'"))
{
return false;
}
else
{ // check max id
$max_rows = $DB_site->query_first("SELECT MAX(phrasetypeid) + 1 AS max FROM " . TABLE_PREFIX . "phrasetype WHERE phrasetypeid < 1000");
$phrasetypeid = $max_rows['max'];
if ($phrasetypeid)
{
$DB_site->query("INSERT INTO " . TABLE_PREFIX . "phrasetype (phrasetypeid, fieldname, title, editrows) VALUES ($phrasetypeid, '" . addslashes($phrasegroup_name) . "', '" . addslashes($phrasegroup_title) . "', 3)");
$DB_site->query("ALTER TABLE " . TABLE_PREFIX . "language ADD phrasegroup_" . addslashes($phrasegroup_name) . " MEDIUMTEXT NOT NULL");
return $phrasetypeid;
}
}
return false;
}
if ($_REQUEST['name'] AND $_REQUEST['title'])
{
add_phrase_type($_REQUEST['name'], $_REQUEST['title');
}
?>
Run newfilename.php?name=(NEWPHRASENAME)&title=(NEWPHRASETITLE)
evenmonkeys
07-16-2005, 05:53 PM
It's not working...
Fatal error: Call to a member function on a non-object in /home/???/domains/???/public_html/pp/admincp/create_new_phrase.php on line 12
Adrian Schneider
07-16-2005, 07:36 PM
Sorry I had a typo on the add_phrase_type line near the end
add_phrase_type($_REQUEST['name'], $_REQUEST['title');
should be
add_phrase_type($_REQUEST['name'], $_REQUEST['title']);
But that wasn't the cause of your error message, you can't run it from the ACP. If you want security (beside just deleting it after) you can add
if (!is_member_of($bbuserinfo, 6))
{
print_no_permission();
}
after
require ("./global.php");
Link14716
07-16-2005, 07:41 PM
No, the cause of the error is that your code is for 3.0.x, not 3.5.0. ;)
Here's your code changed for 3.5.0:
<?php
require_once("./global.php");
if (!is_member_of($vbulletin->userinfo, 6))
{
print_no_permission();
}
// ################################################## ###########################
// function to allow modifications to add a phrasetype easily
function add_phrase_type($phrasegroup_name, $phrasegroup_title)
{
global $db;
// first lets check if it exists
if ($check = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "phrasetype WHERE fieldname = '$phrasegroup_name'"))
{
return false;
}
else
{ // check max id
$max_rows = $db->query_first("SELECT MAX(phrasetypeid) + 1 AS max FROM " . TABLE_PREFIX . "phrasetype WHERE phrasetypeid < 1000");
$phrasetypeid = $max_rows['max'];
if ($phrasetypeid)
{
$db->query_write("INSERT INTO " . TABLE_PREFIX . "phrasetype (phrasetypeid, fieldname, title, editrows) VALUES ($phrasetypeid, '" . $db->escape_string($phrasegroup_name) . "', '" . $db->escape_string($phrasegroup_title) . "', 3)");
$db->query_write("ALTER TABLE " . TABLE_PREFIX . "language ADD phrasegroup_" . addslashes($phrasegroup_name) . " MEDIUMTEXT NOT NULL");
return $phrasetypeid;
}
}
return false;
}
if ($_REQUEST['name'] AND $_REQUEST['title'])
{
add_phrase_type($_REQUEST['name'], $_REQUEST['title']);
}
?>
Adrian Schneider
07-16-2005, 07:44 PM
That might do it. :)
evenmonkeys
07-16-2005, 10:34 PM
I had to run "name=NEWPHRASENAME&title=NEWPHRASETITLE" for it to work, however, when I tried adding a phrase to the phrase type, I got a mysql error.
deathemperor
05-30-2006, 03:57 PM
the function add_phrase_type works, without modify anything, just remember to use this along: require_once(DIR . '/includes/adminfunctions_language.php');
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.