markcl
markcl
Reputation Top 1%
Mark Christian Lopez
7 Snippets  (128th place)
Published
4 Channels
Created
3 Channels
Following
1034 points  (41st place)
Reputation
Junior Code Generator
Serious Code Generator
Junior Publisher
Serious Publisher
Junior Topic Hub
Serious Topic Hub
Senior Topic Hub
Master Topic Hub
Guru Topic Hub
Junior Trend Maker
Serious Trend Maker
Senior Trend Maker
Master Trend Maker
Guru Trend Maker
Junior Popular Coder
Serious Popular Coder
Junior Autobiographer
Serious Autobiographer
Senior Autobiographer
Junior Snip2Coder
Serious Famous Coder

Recent Snippets See all snippets by markcl

public by markcl  2805  2  6  0

Add Image Gallery to Page

<?php
class PortfolioItem extends Page {
    private static $db = array(
        'TrailerVideoURL' => 'Text',
    );

    private static $has_many = array(
        'Still' => 'Image'
    );

    function getCMSFields() {

        $fields = parent::getCMSFields();

        $fields->addFieldToTab(
            'Root.Upload',
            $uploadField = new UploadField(
                $name = 'GalleryImages',
                $title = 'Upload one or more images (max 10 in total)'
            )
        );
        $uploadField->setAllowedMaxFileNumber(10);

        return $fields;
    }
}
class PortfolioItem_Controller extends Page_Controller {
}

class GalleryImageExtension extends DataExtension {
    private static $belongs_one_many = array('Galleries' => 'GalleryPage');
}

Image::add_extension('GalleryImageExtension');
;

public by markcl  3107  7  5  2

Change Directory and File Permissions Properly For Linux Web Server

Sets file permissions to 644 and directory permissions to 755.
find [YOURDIR] -type d -exec chmod 755 {} \;
find [YOURDIR] -type f -exec chmod 644 {} \;
;

public by markcl  3397  7  5  1

Git Clone into non empty directory

git init
git remote add origin PATH/TO/REPO
git fetch
git reset --hard origin/master  
;

public by markcl  2918  9  5  1

Linux Sort Folders By Size

du --max-depth=1 -h | sort -hr
;

public by markcl  3003  0  5  0

Send Email

PHP
public static function appMail($subject, $message, $recipient){
		$to      = $recipient;
		$subject = $subject;
		$message = $message;
		$headers = 'From: admin@careel.com' . "\r\n" .
			'Reply-To: admin@careel.com' . "\r\n" .
			'X-Mailer: PHP/' . phpversion();

		mail($to, $subject, $message, $headers);
	}
;