joomla > 笔记1

** 在TITLE 后加网站名字

在 <jdoc:include type="head" />之前加進:

 <?php$mydoc =& JFactory::getDocument();

$mytitle = $mydoc->getTitle(); 
$conf =& JFactory::getConfig();
$sitename = $conf->getValue('config.sitename'); //取得網站名稱 
$mydoc->setTitle($mytitle.' - '.$sitename);
?>

**  列表查询

 

$db->setQuery("SELECT * FROM  `jos_users` WHERE  `block` =0  AND  `gid` =24");

$q_user=$db->loadObjectList();

foreach($q_user as $q_user_list){

echo $q_user_list->name.'<BR>';

}

**  用户注册

 

$db =& JFactory::getDBO();

 

 

$reg_date = date("Y-m-d H:i:s");

$q_i_1=$db->setQuery("INSERT INTO `jos_users` (`id` ,`name` ,`username` ,`email` ,`password` ,`usertype` ,`block` ,`sendEmail` ,`gid` ,`registerDate` ,`lastvisitDate` ,`activation` ,`params`)VALUES (NULL , '".$post['name']."', '".$post['user_name']."', '".$post['email']."', MD5( '".$post['pwd']."' ) , 'Author', '0', '0', '19', '".$reg_date."', '0000-00-00 00:00:00', '', '');");

$f_i_1=$db->query($q_i_1);

$r_i_2_id = $db->insertid($f_i_1);

$q_i_3=$db->setQuery("INSERT INTO `jos_core_acl_aro` ( `id` , `section_value` , `value` , `order_value` , `name` , `hidden` ) VALUES (   NULL , 'users', '".$r_i_2_id."', '0', '".$post['name']."', '0' );");

$f_i_3=$db->query($q_i_3);

$r_i_5_id = $db->insertid($f_i_3);

$q_i_4=$db->setQuery("INSERT INTO `jos_core_acl_groups_aro_map` ( `group_id` , `section_value` , `aro_id` ) VALUES ( '19', '', '".$r_i_5_id."' );");

$f_i_4=$db->query($q_i_4);

 

 

 

** 获取 新 插入 ID

echo $db->insertid();

 

** $user = &JFactory::getUser();  $user->get('gid') 等于 jos_core_acl_aro_groups  表中的 id,   jos_users 中的gid 即 groups 的IP

**  组件开发 参考 这个地址 http://wenku.baidu.com/view/32cff33383c4bb4cf7ecd167.html

**   JOOMLA  弹出 BOX 

** module 读取 xml  在 module.php  , $params->get( 'custom_code' )

** 输出JOOMLA 跟目录 路径 的常量 JPATH_ROOT     JPATH_ADMINISTRATOR

** 库

$app = JFactory::getApplication();

$app->input->getCmd('Itemid', '');

 

$app = JFactory::getApplication();

$menu = $app->getMenu();

$mytitle = $menu->getActive();  //输出当前页相关属性

$menu->setActive(627); $menu->setActive($_REQUEST['Itemid']); //设置当前Item

$site_name = $app->getCfg('sitename');

 

** 跳转到登录 再 跳转

1
2
3
$app  = JFactory::getApplication();
 
$app ->redirect(JRoute::_( 'index.php?option=com_users&view=login&return=' . base64_encode (JRoute::_( 'index.php?option=com_joomfaq&view=category' )), false),  '请先登录' );

 

** 网站 主域名 JURI::base()

** 修改 configuation.php 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
$config  = JFactory::getConfig();
$config ->set( 'joom_faq_need_check' '3333' );
writeConfigFile( $config );
function  writeConfigFile(JRegistry  $config )
{
     jimport( 'joomla.filesystem.path' );
     jimport( 'joomla.filesystem.file' );
 
     // Set the configuration file path.
     $file  = JPATH_CONFIGURATION .  '/configuration.php' ;
 
     // Get the new FTP credentials.
     $ftp  = JClientHelper::getCredentials( 'ftp' , true);
 
     // Attempt to make the file writeable if using FTP.
     if  (! $ftp [ 'enabled' ] && JPath::isOwner( $file ) && !JPath::setPermissions( $file '0644' ))
     {
     JError::raiseNotice( 'SOME_ERROR_CODE' , JText::_( 'COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE' ));
     }
 
     // Attempt to write the configuration file as a PHP class named JConfig.
     $configuration  $config ->toString( 'PHP' array ( 'class'  =>  'JConfig' 'closingtag'  => false));
     if  (!JFile::write( $file $configuration ))
     {
     $this ->setError(JText::_( 'COM_CONFIG_ERROR_WRITE_FAILED' ));
     return  false;
     }
 
     // Attempt to make the file unwriteable if using FTP.
     if  (! $ftp [ 'enabled' ] && JPath::isOwner( $file ) && !JPath::setPermissions( $file '0444' ))
     {
         JError::raiseNotice( 'SOME_ERROR_CODE' , JText::_( 'COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE' ));
     }
 
     return  true;
}

猜你喜欢

转载自mft.iteye.com/blog/1997354