drupal

Drupal Conditional PHP if admin or user has certain role

帅比萌擦擦* 提交于 2019-12-23 17:49:59
问题 The following will do 'something' if the user is admin. <?php if (($is_admin)) : ?> do something <?php endif; ?> How can I change this so 'something' will happen if the user is admin or has a certain role? Thanks 回答1: Roles are stored in $user->roles . To check "if the user is admin or has a certain role" you can simply: if ($is_admin || in_array('some_role', $user->roles)): 回答2: For checking if the user belongs to one or more roles, you can do: global $user; $allowed_roles = array('customer'

drupal 7 custom schema error datetime

旧巷老猫 提交于 2019-12-23 15:53:16
问题 I have the following schema (generated from an existing table with the schema module (7.x-1.0-beta3) in a custom module. function myproject_entities_schema() { // --------------------------------------------------------------------------------- // MESSAGE // --------------------------------------------------------------------------------- $schema['myproject_entity_message'] = array( 'description' => 'The base table for myproject message instances', 'fields' => array( 'id' => array(

Does anyone know of a faceted search solution for Drupal 7?

人走茶凉 提交于 2019-12-23 12:25:42
问题 Faceted Search module is not being moved to Drupal 7. What are my alternatives? 回答1: The Search API module is new for Drupal 7, and allows you to choose from a variety of backends, including Solr, Xapian, native database and others. It supports faceted search irregardless of which backend is used. 回答2: One option is an apache solr integration http://drupal.org/project/apachesolr or a self written lucene search module. 回答3: I have set a faceted search up in Drupal 7 using the Search API which

Theming Drupal 7's Ubercart “/cart” page

前提是你 提交于 2019-12-23 11:55:15
问题 I'm trying to theme Drupal 7's Ubercart 3 /cart page, but I'm struggling to find the theming function to do so. I believe the right code may be located in template.tpl.php , but I am not sure. Where in Drupal is the code to theme this page? 回答1: Create a new template file and name it page--cart.tpl.php For more information about Drupal theming suggestions: http://drupal.org/node/1089656 (Don't forget to clear the cache after adding the new template file) Another way to use Devel module with

Adding microdata or schema.org for breadcrumb SEO in Drupal 7

别来无恙 提交于 2019-12-23 09:51:37
问题 I'm currently a little confused about microdata and schema.org. Is microdata and schema.org the same? I read the Google and Microsoft documentation, but that didn't helped me to get the difference between this two names. So far I understood this I have produced this HTML code: <span itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> <a href="/" itemprop="url"><span itemprop="title">My Page</span></a> </span> <span itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> <a href="

Drupal Features include Theme

痴心易碎 提交于 2019-12-23 08:36:48
问题 Is it possible to include a theme in a Drupal Feature? if so how? 回答1: Not at the moment, unfortunately. Features basically consist of things that can be cleanly exported out of and imported into Drupal via various event hooks. Themes are an entirely different animal. Theoretically, if you want to override some markup in your Feature (custom tpl.php files for your own content type for example), you could include the custom tpl.php file and use theme-related hooks in the Feature's module file

Postgres SSL error

放肆的年华 提交于 2019-12-23 07:25:42
问题 I'm trying to run a Drupal migration via SSH and drush (a command line shell), copying data from a postgres database to mysql. It works fine for a while (~5 mins or so), but then I get the error: SQLSTATE[HY000]: General error: 7 SSL [error] SYSCALL error: EOF detected The postgres database connection seems to have gone, and I just get errors: SQLSTATE[HY000]: General error: 7 no [error] connection to the server It works fine locally, so I think the problem must be with postgres and running a

How add trigger to mysql Through Schema API

我们两清 提交于 2019-12-23 05:36:11
问题 Through Schema API (file mymodule.install in Folder sites\all\modules\mymodule). trigger in mysql: delimiter | CREATE TRIGGER testref AFTER INSERT ON users FOR EACH ROW BEGIN INSERT INTO beep SET uid = NEW.uid; END; | delimiter ; 回答1: There is no specific API for that. Try http://api.drupal.org/api/drupal/includes--database.pgsql.inc/function/db_query/6 Also remember that triggers are not standardised across different databases. It would be a better idea (or maybe as a fallback) to do that

Drupal中hook_theme函数用法

混江龙づ霸主 提交于 2019-12-23 05:13:57
在开发的时候不免要使用到drupal theme 定义。 举个简单的例子: 复制代码 代码如下: <?php function modulename_theme() { //开始定义自己的theme 使用api hook_theme return array( //返回theme 数组 'hot_news' => array( // 给定义的theme 定义一个名称 'arguments' => array('title' => NULL, 'teaser' => NULL, 'link' => NULL), //这些都是要传递的参数,具体是在使用 theme('hot_news',arg1,arg2,arg3),这时使用到。 'template' => 'hot_news', //模板名称,它会自动搜索hot_news.tpl.php模板文件 'file' => 'get_page.inc', //这个是定义相关函数的文件,根据需要自行定义。 'path' =>drupal_get_path('module', 'modulename'), //得到文件路径,如果theme('hot_news',arg)在template.php里面使用,需要告诉drupal具体位置,不定义,如果在 template使用,它只能在template.php同目录下查找。默认和主题同目录。 ), )

[Drupal] duplicated entry for meta http-equiv=\"Content-Type\" in the head-area

不打扰是莪最后的温柔 提交于 2019-12-23 05:13:03
look in the source of the d.o theme: <! DOCTYPE html > < html xmlns ="http://www.w3.org/1999/xhtml" xml:lang ="en" lang ="en" dir ="ltr" > < head > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> one <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> is definitly enough. That is the problem of D6, you will find this details in http://drupal.org/node/1014280 http://drupal.org/node/451304 here is an example to resolve it. In you theme, here is demo theme, template.php file,