Results tagged “web development” from muse

This is a solution to mix public downloads and protected folders.

For this, you will need CCK, specifically CCK FileField and Content Permission. Also mod_rewrite should be enabld.

First, add a new file field to a content type, and configure its path to the directory that will be protected. For example, if /files/protected is the directory that will contain protected files, then you can either set that as the path or a folder within it.

If you have already set /files as your file system path, then there should be a .htaccess file created by drupal. You should copy that into each of the protected folders. If you don't, you may get 404 errors.

Open the .htaccess file in your root drupal directory, add the following line to the end of mod_rewrite rules:

RewriteRule ^files\/(protected\/.*)$ index.php?q=system/files/$1 [L,QSA]

Replace protected with your top-level protected folder name. If you have other custom rewrite rules you should be more careful about where you put the above line. Putting it at the end works for me.

Lastly, on your 403 page, you can examine if user is requesting a file in a protected directory using request_uri() and strpos().

Customize Ubercart Product Page

|

Here's a little snippet of code to customize ubercart product page template so that the contents are grouped into tabs.

You need Tabs and CCK Fieldgroups Tabs.

Go to yoursite/admin/content/node-type/product/fields and add some cck groups and fields, then display them properly (tabs for full node).

Create node-product.tpl.php. Paste the following php code in (enclose it with php tags):

$form = array();
$form['ptabs'] = array(
'#tabset_name' => 'ptabs',
'#type' => 'tabset',
);
$i = 0;

// shows a summary of the product
$summary;
$summary .= $node->content['weight']['#value'];
$summary .= $node->content['dimensions']['#value'];
$summary .= $node->content['body']['#value'];
$form['ptabs'][$i] = array(
'#type' => 'tabpage',
'#title' => t('Summary'),
'#content' => $summary,
);
$i++;

// add other tabs if applicable
if (!empty($node->content['fieldgroup_tabs'])) {
	foreach ($node->content['fieldgroup_tabs'] as $key => $value) {
		if (is_array($value)) {
			if ($value['#type'] == 'tabpage') {
				$form['ptabs'][$i] = array(
				'#type' => 'tabpage',
				'#title' => $value['group']['#title'],
				'#content' => $value['group']['#children'],
				);
				$i++;
			}
		}
	}
}

The page should always have a tab called Summary, and other tabs that you added for the content type if they are not empty (cck fieldgroup tabs module validates this). If you don't wish to have the Summary tab, simply delete that part of code.

Feel free to share the code.

Webform is a great module, but it doesn't send confirmation email, so here is a quick fix if you are running on Drupal 6.x.

To get the submitted value of a form component, you can use $form_values['submitted_tree']['component_key'] where component_key should be replaced by your component key. If the component is in a fieldset, access it by $form_values['submitted_tree']['fieldset_key']['component_key'] where fieldset_key should be replaced by your fieldset key.

To send the email I chose to use drupal_mail() function, of course there are other ways.

Here is an example:

$from = "example@example.com";
$to = $form_values['submitted_tree']['email'];
$user = $form_values['submitted_tree'['name'];
$body = "Hello " . $user . ",\nThis is a message.";
drupal_mail('webform_extra', 'confirmation_key', $to, language_default(), array('body' => $body), $from, TRUE);
function webform_extra_mail($key, &$message, $params) {
$message['subject'] = "Confirmation email";
$message['body'] = $params['body'];
}

Hands-On Experience of Symphony

|

During the past week I have been developing a website for my school's photography club. It's a blog-like photo gallery thats supports multiple authors, I also implemented author registration for the sake of convenience.

After looking at MovableType (and its plugins), TYPO3 (and its extensions), ExpressionEngine, and WordPress, I decided to go with Symphony. The main reason I chose Symphony is because of its extremely user-friendly and minimalistic backend interface. So people who are not-so-good-at-computers won't get totally confused. Believe me, there are people who don't know how to post a photo in WordPress; user-friendliness is important.

However, I have never had any experience with XSL or XSLT, so I spent half of the development time learnig XSLT. But it is easy to learn since it doesn't really have complicated functions and whatnot. BTW, I know Symphony beta 2.0 is out but since I don't have the time to constantly maintain the website I used 1.7.

Here is a list of functions I added/modified, in addition to the default ones.

  • Homepage as an index of photos
  • Categories of photos
  • Featured photo
  • Pagination
  • Author Registration

Started by off by adding Custom Fields(CF) and pages. I was a bit confused with Data Sources and Utilities at the beginning and wasted some time (didn't read any documentation but who reads them anyway?). Applied my limited knowledge of XSLT when editing pages and utilities. Eventually I added new controllers to work with pages. It took me some time to realize that Utilities must associate with Data Source to work, and Controllers pull data from Elements, which you can choose which ones to include.

This page is extremely helpful, and also search in the overture forum when you have problems, searching in Google is not really helpful.

在苹果系统上安装TYPO3

|

其实很简单, in-genia 早就发布了英文版的集成包, 只需要运行一个安装程序, mysql 和 php 以及 typo3 就都安装在本地电脑上了。下载链接在 这里 。最新的版本在最底部(德国人的奇怪思维)。

软件主要是通过MAMP来运行的, 该软件还包括一个简单的widget, 可以控制mysql服务器的运行以及打开主程序界面 (一个网页而已)。 php可以选择 php4 或 php5。

今天成功地用TYPO3的TypoScript和Spry Accordion Widget(当然还有CSS和JS)结合在一起实现了动态(会动的!)菜单。TypoScript的确是很强大,不过在 TSref 里找东西有点烦人,而且也没有很完整的教程,目前我还在处于瞎子状态中。Google找了半天发现德文资料居多,比英文还多,这倒是头一次碰到。下面是昨天发现的几个还算有点用的网站:

下面是setup的部分代码

marks.ACCORDION = HMENU
 marks.ACCORDION.special = directory
 marks.ACCORDION.special.value = 48
 marks.ACCORDION.1 = TMENU
 marks.ACCORDION.1.target = page
 marks.ACCORDION.1 {
  expAll = 1
  noBlur = 1
  wrap = |
  NO {
   wrapItemAndSub = <div class="AccordionPanel">|</div>
   linkWrap = <div class="AccordionPanelTab">|</div>
   doNotLinkIt = 1
  }
 }
 marks.ACCORDIONL.2 = TMENU
 marks.ACCORDIONL.2 {
      wrap = <div id="AccordionPanelContent1" class="AccordionPanelContent"><ul class="list1">|</ul></div>
  target = page
  noBlur =1
  NO {
   RO = 1
   ATagBeforeWrap = 1
   allWrap = <li>|</li>
   linkWrap= |
  }
 }

用.special属性生成只有pid=48的网页目录,然后生成第2级目录。

下面是template文件的代码:

<div id="Accordion1" class="Accordion">
###ACCORDIONL###
</div>

TypoScript还算比较容易上手,有1个星期基本上就没问题了。不过TYPO3实际用起来还没经验,估计要等到1,2个月后才知道了。