drupal

Add meta data to a Drupal page that isn't in the CMS?

泄露秘密 提交于 2019-12-31 04:02:32
问题 I'm new to Drupal and I'm having to work on a site coded by another developer. We have found and installed the Metatag module in order to give us access to change metadata on content inside the CMS. This is great for most things, however there are some types of content (not sure the exact Drupal terminology here) such as Testimonials and Case Studies. Each individual testimonial and case study has their own area in the CMS to edit the content, and these each have the Metatag module area to

Drupal性能优化:蜜蜂培训性能优化一

会有一股神秘感。 提交于 2019-12-30 23:55:23
大家一直都说Drupal的性能不怎么样,跑起来慢,即使不是在用户量大的时候,最近公司的蜜蜂培训产品在一个客户的使用过程中,由于用户量及数据量的激增,就遇到了比较大的性能问题,这篇文章就记录了整个优化过程,最终将性能调整到了正常水平。 蜜蜂培训系统由于是包含报名、签到、投票、评估、考试等场景,而这些场景往往都是有时间点的限制,这就造成较大的用户并发量。刚开始遇到性能问题的时候,大家的第一感觉肯定都是硬件水平跟不上,随后我们对服务器进行了扩容,但发现收效甚微,随着用户不断增加系统也越来越慢,于是我们开始着手优化系统。 首先我们从数据库开始,开启了mysql 慢查询日志,来看看有没有哪些逻辑的数据库查询有问题,这一看真吓一跳,有一个关键逻辑的sql居然最长要执行68秒! 找到了问题所在,那么赶紧着手优化吧,来看看到底这个sql的执行时间到底耗费在了哪里,这里我们用 mysql 的 explain 命令来分析一下这个sql的执行计划, drush sql-cli 进入mysql命令行,敲入 explain + sql 就会打印出这个sql 的执行计划: 参考 explain 命令的说明,可以看到上图signup表是问题所在,这里没用到索引,使用了全表扫描和关联操作,经过对sql 和场景的分析,我们对sql中的这几个关键表对应的添加了新的索引: function wl_signup

Auto-updating width/length/area using jQuery and Drupal6

…衆ロ難τιáo~ 提交于 2019-12-30 11:48:23
问题 I'm using Drupal to create a measurement sheet (Measurement sheets in Drupal 6) and am at a point where I have all the fields in place, I just need to write some jQuery that auto-updates the appropriate field when the user enters data. Code below: jQuery(document).ready( function ($) { $('input').change( function() { $parent = $(this).parent("td").children("div").children("div"); length = $parent.children("div[id*='field-length-0-wrapper']").children("div.container-inline").children('div[id*=

List of events with a list of timestamps, grouped by hour in a tabular display, in PHP.

流过昼夜 提交于 2019-12-30 11:13:27
问题 While refactoring, I am looking for an optimised algorithm for a timetable (calendar) in PHP. I have a list of events which have a list of timestamps. This must be presented in a tabular way. The current code works, but has a) quite some quircks and is b) very inflexible. I am looking to refactor this piece and looking for input on optimised ways. Example here, notice the header of the table bearing the hours. And the times within that hour being grouped in that column. One event, having two

Drupal 7 Views - How to access unformatted $row variable in a custom template?

你说的曾经没有我的故事 提交于 2019-12-30 09:27:41
问题 I just installed Views module for Drupal 7 and am trying to find out how to customize it. So far, I have done the following things. Created a content type specified views and named it as 'videotest'. Created a custom theme as 'views-view-list--videotest.tpl.php' The page is working without a problem. Here is the custom template code I used (this is the default template from Views): <?php print $wrapper_prefix; ?> <?php if (!empty($title)) : ?> <h3><?php print $title; ?></h3> <?php endif; ?> <

How to get URL argument in Page body by PHP?

天大地大妈咪最大 提交于 2019-12-30 06:50:34
问题 On a Drupal site, PHP code is enabled for Page body content. How can I get the argument and its value in PHP code? For example, I'd like to get ref and 33002 from: http://example.com/node/1?ref=33002 In the following code: <?php print arg(0); print arg(1); print arg(2); print arg(3); ?> I can get node and 1 , but nothing about ref or 33002 . Thanks! 回答1: Use this: <?php $a=$_REQUEST['ref']; echo "The value of the ref parameter is ".$a; ?> 回答2: You can use drupal_get_query_parameters() as

Creating Drupal CCK content programmatically/ via API

二次信任 提交于 2019-12-30 04:56:29
问题 I am working with a Drupal 6.x system to create exercise / personal training programmes, and am using the CCK with content types of Exercise and Programme, where Programme contains a few header fields and a list of node references to the exercises it consists of. This works great and I can manually create programmes which work fine. I now wish to create a module which can generate these programs automatically based on a number of algorithms I have developed, the process will look like: Load

Good beginners material/advice on Drupal

冷暖自知 提交于 2019-12-30 00:39:08
问题 I'm learning Drupal and whould like to ask you about some good material for a beginner on this subject. Any book, website or article is welcome. I whould like to hear to any good advice for someone like me, which is just starting to know Drupal and CMSs in general. Currently, I'm using as my basic source the official website of the project. 回答1: You can use Drupal for a lot of things and in a lot of ways, so it's hard to say which is the best for you. If your aim is to use Drupal as a

Working with version control on a Drupal/CMS project

梦想与她 提交于 2019-12-29 18:45:13
问题 I was wondering how teams that develop sites using Drupal (or any other CMS) integrate version control, subversion, git or similar, into their workflow. You'd obviously want your custom code and theme files under version control but when you use a CMS such as Drupal a lot of the work consists of configuring modules and settings all of which is stored in the database. So when you are a team of developers, how do you collaborate on a project like this? Dumping the database into a file and

Regex extract variables from [shortcode]

空扰寡人 提交于 2019-12-29 07:13:20
问题 After migrating some content from WordPress to Drupal, I've got som shortcodes that I need to convert: String content: Irrelevant tekst... [sublimevideo class="sublime" poster="http://video.host.com/_previews/600x450/sbx-60025-00-da-ANA.png" src1="http://video.host.com/_video/H.264/LO/sbx-60025-00-da-ANA.m4v" src2="(hd)http://video.host.com/_video/H.264/HI/sbx-60025-00-da-ANA.m4v" width="560" height="315"] ..more irrelevant text. I need to find all variables within the shortcode [sublimevideo