markcl
markcl
Reputation Top 1%
Mark Christian Lopez
7 Snippets  (116th place)
Published
4 Channels
Created
3 Channels
Following
Aug 10, 2014
Last Visit
Aug 11, 2013
Registered
758 points  (27th 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

Recent Snippets See all snippets by markcl

public by markcl created Aug 6, 2014  239309  1  5  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 created Jul 23, 2014  631  1  4  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 created Jul 22, 2014  759  1  4  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 created Jul 22, 2014  615  3  4  1

Linux Sort Folders By Size

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

public by markcl created Aug 13, 2013  610  0  4  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);
	}
;