网站地址:http://www.nysenate.gov/" R4 d3 a7 f. |- e6 q/ ]
内容过多,固不对机器人翻译进行整理,请实时参考原文!
--------------------------------------------------------------------------
After winning control of the New York State Senate for the first time in almost 50 years, the Democratic party turned to Advomatic to quickly deploy a new website powered by Drupal. There were many challenges to be overcome, and their requirements pushed the envelope in some areas such as permissions and work flow. In the end, this site stands as a testament to what can be accomplished by a focused and experienced development team using the power and flexibility offered by Drupal and its community.
在近50年来第一次赢得了纽约州参议院的控制权后,民主党转向Advomatic快速部署一个新的网站由Drupal供电。有许多必须克服的挑战,他们的要求推在某些领域,如权限和工作流程的信封。最后,本网站代表证明了可以通过集中和经验丰富的开发使用Drupal和其社区所提供的力量和灵活性的团队完成。
旧版:
![](http://drupal.org/files/images/nyss.preview.png)
新版[点击查看大图]:
Multi-Site Structure/多站点结构
Previously, each Senator controlled their own little section of the web with a proprietary ASP-driven site, with little continuity between them. The Senate wanted to allow each senator to continue to control their individual sub-sites, but wanted content to be more easily shared between the sites, and for desired articles from individual senators to occasionally be featured on the main section of the site.This obviously required a multi-site solution, and this was the first issue to be tackled, since its implementation would inform the rest of the development.
以前,每名参议员控制的专有驱动ASP网站自己的网页的小部分,它们之间的小连续性。参议院希望,让每名参议员继续控制各自的子网站,但希望内容可以更容易地在站点之间共享,并从个别参议员所需的物品,偶尔上的site.This的主要部分特色明显需要多站点的解决方案,这是第一个要解决的问题,因为它的实施将告知其余的发展。
We looked at several proposed solutions and modules that help with deploying such a site, and in the end decided to create a custom method (similar to what we deployed for Air America Radio), because of the unique requirements. This consisted of creating a 'Senator' content type, to which every other content could reference, which would be used for grouping. For instance, Senator Malcom A. Smith's section groups all of his content, with a unique header, a specialized menu navigation, blog, etc.
我们看了几个建议的解决方案和模块,帮助部署这样一个网站,并在年底决定创建一个自定义的方法(类似我们部署的空气美国收音机) 1 v' \# w2 a4 a6 I" O8 f& Z
,由于独特的要求。这包括建立一个'参议员'的内容类型,所有其他内容可以参考,这将用于分组。例如,参议员马尔科姆A.史密斯的部分群体有一个独特的头,一个专门的菜单导航,博客,他的所有内容,等等。
![](http://drupal.org/files/images/nyss-red-banner.png)
The design (created by our very own Amanda Luker and Jack Haas) called for two basic themes, dependent on party affiliation. We simply added a drop-down field with a 'Blue' and 'Red' option, originally with the intention of switching the global $custom_theme as needed. In the end, we decided to simply print that in the body class, as it was easier to simply use a CSS switch rather than an entirely unique theme. We used Cufón for image replacement throughout the site.
两个基本主题,依赖于党派呼吁设计(创造我们自己的阿曼达Luker和杰克·哈斯) 。我们只是说, 7 q7 k5 K& I/ q# {1 ^
'蓝'和'红'的选项,原本需要交换的全球美元custom_theme的意图,下拉字段。最后,我们决定简单地打印在体内类,因为它是简单地使用CSS交换机,而不是一个完全独特的主题。我们使用Cufón更换整个网站的形象。
Menu Navigation/主导航菜单
![](http://drupal.org/files/images/tn-nyss-menu.png)
Menu navigation was far more challenging to implement. They wanted each senator to have its own menu for primary navigation and have the menu automatically pre-populated, but to also allow each senator to override the menu as desired. We quickly dismissed the standard menu as an option, as we did not want to open up the can of worms of allowing full access to the system menu by a disgruntled office editor. Even if we modified the access to only allow access to a specific menu, that wouldn't solve the need to automatically create a suitable menu from a template, which would serve 95% of the senators.
菜单导航是实现更具挑战性。他们希望每名参议员有其自己的主导航菜单,菜单中有自动预填充,但也让每名参议员需要重写的菜单。我们迅速解雇的标准菜单,作为一个选项,因为我们不想打开一罐蠕虫允许完整存取由心怀不满办公室编辑器系统菜单。即使我们修改了访问,只允许访问一个特定的菜单,这不会解决需要自动创建一个合适的模板,这将成为95 ; t4 ?# H) u6 S
%的参议员菜单。
In the end, we opted to use a Link field for the menu, which would be printed by overriding $vars['primary_links'] in phptemplate_preprocess_page. Then we simply checked the path to see if we were on a page referencing a senator, in which case we would do the override. We also implemented a custom token for this, so that we could fill it with such useful default paths as [senator]/blog and [senator]/gallery.
最后,我们选择使用的菜单,其中将印被重写美元VARS [ ' primary_links ] # Y7 M! W0 C1 V% K. `& Z% m
phptemplate_preprocess_page的,链接字段。然后我们只需选中的路径看,如果我们在页面引用参议员,在这种情况下,我们会做覆盖。我们还实施了这是一个自定义的令牌,这样我们就可以填写有用的默认路径,如[参议员]
2 t9 m0 [$ e) _2 F2 E: g/博客[参议员] /画廊。
As there were many other cases for which we needed to know if a specific page load referenced a senator, we put all the arg sniffing in a static variable during hook_init, so that we could easily discover that: a call to nyss_senator() would return either FALSE or the referenced senator's node.
由于有许多其他情况下,我们需要知道,如果一个特定的页面加载引用参议员,我们把所有的精氨酸在在hook_init静态变量的嗅探,因此,我们可以很容易地发现:一个nyss_senator % m" V E9 u$ f0 v7 L; P' A
()的调用将返回FALSE或引用参议员的节点。
Data Migration/数据迁移
After creating the basic content types, with required senator node reference fields, it was time to populate our site. The original vendor had provided us with a backup disk with about 12,000 pieces of content. We wrote a quick migration script to map the original data with our new content types. In the past, we would simply do this over the command line. This time, I wanted to dive into Drupal 6's batch operations, which offers a slick interface, so I put the scripts into a special one-time only admin callback so I could watch a druplified progress bar while I ate popcorn.
创建基本内容类型后,与所需的参议员节点引用字段,它是时间来填充我们的网站。原来的供应商提供了约12,000件的内容与备份磁盘。我们写了一个快速的迁移脚本映射与我们的新内容类型的原始数据。在过去,我们只是做了命令行。这一次,我想潜入Drupal 0 \% p) Q6 x- g: W6 e
6中的批量操作,它提供了一个漂亮的界面,所以我把一个特殊的时间只有admin回调脚本,这样我就可以观看druplified进度栏,而我吃爆米花。
The original data being in a Microsoft Access database presented several problems for migration. Firstly, the original dump was corrupted, as the original migration returned about three quarters of the nodes with odd characters. After investigating why apostrophes were being turned into ’ (among other problems), we learned the data had been corrupted when the original vendor backed up the database. Normally, PHP's iconv would have been able to convert from Latin-1 character encoding to the required UTF-8. However, the corruption was in the data itself, which meant we had to get a new backup. A few hours later, the new backup was delivered, which was properly encoded.
Microsoft 9 G; L3 z' `* [, w
Access数据库中的原始数据,提出了迁移的几个问题。首先,原始转储被损坏,原迁移约四分之三奇怪的字符的节点返回。调查为何撇号被分为A ™
+ V( ?) G! B9 v3 Q3 G/ _4 x! x# s(其他问题)打开后,我们了解到的数据已损坏时,原来的供应商数据库备份。通常情况下, PHP的的iconv将已经能够转换的Latin-1字符编码所需的UTF -8
" A1 K d3 D! \; ^8 |; {4 f* E" U' g5 L。然而,腐败是在数据本身,这意味着我们必须得到一个新的备份。几个小时后,被送到新的备份,这是正确的编码。
There were other problems with the original data: there was no unique field on the rows, images and pdfs were stored inline (which meant we had to modify those on the fly to match our new consolidated /files folder, and also turn them into suitable file objects for storage in a filefield). Then there was the problem of editing the 300 page State Constitution as a single node.
有与原始数据的其他问题:有没有独特的行场,图像和PDF文件保存联(这意味着我们不得不修改那些符合我们的新的综合/文件夹上的苍蝇,也变成适合他们FileField字段中存储的文件对象) & `* Y* Y6 Y& u
。再有就是作为一个单一的节点编辑300页的国家宪法的问题。
These issues were easily surmountable, and soon we had a working site. Interestingly, the original proprietary CMS didn't have anything approaching Drupal's check_plain, which meant that in the past, some innovative senatorial editors had gotten away with such fancies as displaying a page's title as a JS marquee...
这些问题是很容易克服的,很快,我们有一个工作场所。有趣的是,原来专有的CMS没有任何接近Drupal的check_plain
* k( ~, C0 B ~+ J+ ]5 j3 u" l,这意味着,在过去,一些创新参议院编辑已经得到的,如显示页面的标题作为一个JS选取框幻想...
Editor Permissions/编辑权限
With 12,000 nodes filling in the sections for 60+ senators, not all of whom play nice together, we next had to tackle the roles and permissions for the site. This was not a straight-forward matter: they all had to be able to edit content from their respective senators, but not that from other senators. Additionally, if a senator had multiple editors, they would need to be able to edit each other's work, and we had to account for the possibility of some editors being shared amongst senators.
12,000在60岁以上的参议员,而不是所有的人发挥好一起的部分填充节点,接下来我们不得不对付的角色和权限的网站。这不是一个直接的问题:他们都能够从各自的参议员编辑的内容,但不能从其他参议员。此外,参议员,如果有多个编辑,他们将需要能够修改彼此的工作,我们不得不考虑的参议员之间共享一些编辑的可能性。
We made use of hook_node_access_records and hook_node_grants to handle the grunt work for this. We created a grant realm for the possible field_senator's nid on a node, and mapped this to the office editors assigned to a senator. This in turn was assigned with a user_reference field selecting from a view of users with the Office Editor role. Finally, we altered the menu callback for node/[nid]/edit to check the permissions, to keep folks from being mislead by an edit tab to nowhere.
我们使用hook_node_access_records和hook_node_grants来处理这个繁重的工作。我们创建的赠款领域为可能field_senator的NID节点上,映射这个分配给参议员办公室编辑。这反过来又被分配与1 $ Z1 m8 X$ | x9 \; l( F$ E
user_reference领域从办公室编辑角色的用户的选择。最后,我们改变了节点/ NID ) {3 L$ r; G; \9 j/ c& B" u
/编辑菜单回调检查的权限,继续编辑“选项卡的人被误导走不通。
Flag FTW/标志FTW
![](http://drupal.org/files/images/nyss-flag.preview.png)
We made heavy use of the Flag module throughout the site. This included not only promoting content to the front carousel (which was created using jQuery Cycle) and to other blocks on the front page, but also to a similar carousel and tabs on each senator's page, galleries, and other places throughout the site.
我们整个网站中大量使用的标志模块。这包括前的传送带(创建使用jQuery循环) 2 L/ h. X4 R' i5 p
,并在头版的其他块不仅促进内容,而且还对每名参议员的页面,画廊,和其他地方的类似传送带和标签的整个网站。
Of course, this presented its own set of problems for our unique permissions structure, as a senator should not be able to flag content for another senator. To circumvent the problems, we altered the flag links so they would not appear if the editor did not have permission to edit a specific node.
当然,这提出了它自己的一套问题,我们独特的权限结构,作为一个参议员不应该是能够标记为其他参议员的内容。为了规避问题,我们改变了标志的链接,这样他们就不会出现如果编辑没有编辑特定节点的权限。
Bread and Butter/面包和奶油
Views, of course, filled the site with our content. After creating and finalizing the View blocks and pages, we exported them all for better performance. There were no real problems with this stage of things, except for a few view queries that were not possible to create with the standard UI. In those few cases, we made use of hook_views_query_alter. Additionally, because many of the views required an argument of a referenced senator, and we had a custom token for our senator's path that didn't necessarily match up to the title, we had to write our own views argument handler that we stuck in the argument PHP validation block when required.
的看法,当然,充满了我们的内容的网站。视图块和页创建和定稿后,我们的出口,他们有更好的表现。有没有真正的问题,本阶段的事情,除了几个视图的查询,这是不可能的创建标准的UI 7 I: u& W( i* i; T
。在那些少数的情况下,我们使用的hook_views_query_alter . T3 B% n4 t6 N2 U' ]/ |0 B, G
。此外,因为许多意见需要引用参议员的说法,我们不得不为我们的参议员的路径并不一定匹配的标题自定义令牌,我们不得不写我们自己的看法参数处理程序,我们在坚持需要时的参数PHP验证块。
![](http://drupal.org/files/images/nyss-butter.png)
As a site of any complexity would need, we needed to implement several custom blocks. We have refined a system over several sites that we continued here, that allows for the flexibility allowed with Drupal's custom block system, while extending it to allow things to be easily controlled through code, rather than embedding such things as a block's per-page appearance on the administration form. Basically, when creating a new custom block, we define its visibility as 2 (so the pages are controlled with a PHP callback), and set that to return a custom callback with the $delta. Then if we decide in the future to move one or more blocks to another page, we can change the settings in the callback, rather than submitting each block configuration page individually. To further ease configuration, and take advantage of Drupal's just in time file loading, we also create theme functions automatically when a new custom $delta is added, loading the new theme_custom_block_$delta.tpl.php file as needed.
作为任何一个复杂的网站将需要,我们需要实现几个自定义块。我们已经提炼1几个网站,系统,我们继续在这里,允许Drupal的定制块系统所允许的灵活性,同时扩大它以东西向被轻易控制,通过代码,而不是嵌入1块的每个页面的外观这样的事情,管理形式。基本上,创建一个新的自定义块时,我们定义为2 7 o6 u2 W* S$ `' }! K5 [
(所以页面是一个PHP回调控制) " D& E+ ?% L7 w7 q2 o {& R% J
,其知名度,并设置,返回一个自定义回调与美元三角洲。然后,如果我们决定在未来一个或多个块移动到另一页,我们可以改变在回调的设置,而不是单独提交每块配置页。为了进一步简化配置,并充分利用Drupal的只是时间的文件加载的,我们还创建主题功能时自动添加一个新的自定义$三角洲,加载新theme_custom_block_
2 n; N* S4 X) Y4 \$ delta.tpl.php文件需要。
There are a lot of little things I would love to tell you about, and there was much more that went into creating this site than I can get into without turning this case study into a novel-length exposition. I haven't even discussed Committees, Legislation, or their Open Data project.
有很多小东西,我很想告诉你,有更到创建这个网站比我能不变成这种情况下,研究一种新型的长度博览会将去。我还没有讨论委员会,立法,或他们的开放数据项目。
Advomatic's development team was superb! I was assisted by Jonathan DeLaigle, Amanda Luker, Jack Haas, and Marco Carbone. Overseeing the project were Fred Gooltz and Dylan Clear. A hat tip to EchoDitto who was responsible for the early project management and first draft of wireframes/specifications. Craig Leinoff also jumped in feet first from the Senate's CIO office to help develop the site and get it ready to launch.
I am excited to see more of our government extolling the virtues of Open Source, and am proud to have helped to deliver a robust Drupal site to the New York State Senate.
Aaron Winborn is a developer with Advomatic. Besides development, Advomatic also offers a wide range of other Drupal services, including maintenance and clustered hosting. In addition to helping roll out sites such as the New York State Senate, Air America, andMozilla, Aaron also contributes heavily to the Drupal community, including such modules asEmbedded Media Field and Views SlideShow. He has written Drupal Multimedia, published by Packt Publishing, and is mentoring a Google Summer of Code project to help roll out the upcoming Media module. You can read his blogs at Advomatic and AaronWinborn.com.