Tag Archives: php
The PHP command accepts some interesting parameters which add flexibility to how scripts that you run from your shell or cron jobs are executed.
One of them is -d, which alters a php.ini value for the duration of the command. An example is as follows:
php5 -d memory_limit=128M symfony propel:data-load
This was a real time saver considering the server was not setup with a CLI-specific php.ini, like some are.
if ( comments_open() ) { ?>Let’s say we want to create a field to set the password in plain text from the admin panel, then convert it to sha1 before saving it. Our hypothetical module will be located in backend/modules/admins/, which is a Symfony admin generator module for an AdminUser model.
First we define the getters and setters for the plaintext password in the AdminUser model:
public function setPasswordPlain($plain)
{
if(! empty($plain))
$this->setPassword(sha1($plain));
}
public function getPasswordPlain()
{
return "";
}
Then, in generator.yml we add this field to form sections, using the display parameter:
form:
display: [login, password_plain, email]
If we try the generator now, we’ll get an error message telling us that password_plain widget does not exist, which is true. The new admin generator uses the great Symfony 1.2 forms system, which treats a form as a set of widgets and validators.
If we inspect the lib directory of our generated module we’ll notice the file called adminsGeneratorConfiguration.class.php. This file extends BaseAdminsGeneratorConfiguration which, if we look closely, configures what form is related to this generated module:
public function getFormClass()
{
return 'AdminUserForm';
}
What we have to do is obvious. We extend AdminUserForm, and we override that method to return the name of our new class. In the same lib directory we create the form:
class myAdminUserForm extends BaseAdminUserForm
{
public function configure()
{
parent::configure();
$this->setWidget('password_plain', new sfWidgetFormInput());
$this->setValidator('password_plain', new sfValidatorString(array('max_length' => 255, 'required' => false)));
}
}
and finally we alter the adminsGeneratorConfiguration accordingly:
class adminsGeneratorConfiguration extends BaseAdminsGeneratorConfiguration
{
public function getFormClass()
{
return 'myAdminUserForm';
}
}
I wanted my homepage title to reveal my writing goals and interests. The importance of the title, to me, is obvious:
- It’s one of the first things people notice.
- It’s visible in the window chrome, the tabs, the bookmarks
- It’s something search engines pay attention to
WordPress settings allow you to set the blog title and description. With this modification, the description will be appended whenever a post title is not displayed, to avoid making it extremely long.
Edit the functions.php file of your template and append:
add_filter('wp_title', 'dv_wp_title', 100, 3);
$dv_append_subtitle = false;
function dv_wp_title($title)
{
global $dv_append_subtitle;
if($title === '')
$dv_append_subtitle = true;
return $title;
}
function dv_the_subtitle($sep = '—')
{
global $dv_append_subtitle;
if($dv_append_subtitle)
{
echo $sep ? $sep . ' ' : '';
bloginfo('description');
}
}
Then go to header.php and make your title tag look like this (notice that I added the dv_the_subtitle call)
And that’s it! If you want to customize the separator, which defaults to — pass it as an argument to dv_the_subtitle.
if ( comments_open() ) { ?>Some important and some not-as-important bug fixes in this version. Hopefully this will be the last release candidate before the grand 1.0 release:
- Tables not deleted anymore upon installation
- Fixed SimplePie error report.
- Fixed small post content bug (not hidden by default)
- Fixed cron url
- Removed inverted quotes from queries
- Fixed notices in debug mode
- No error showing for campaigns w/o feeds fixed
Click here to download
As usual, head to Lighthouse for bug reports
if ( comments_open() ) { ?>