Skip to content

Instantly share code, notes, and snippets.

View eklect's full-sized avatar

Tony Mucci eklect

View GitHub Profile
@eklect
eklect / c5-get-all-page-titles.php
Last active August 29, 2015 14:15
How to find all certain type of pages titles in c5
function getAllPagesList($parent,$type) {
$page_list = new PageList();
$page_list->filterByParentID($parent->getCollectionID());
$page_list->sortByName();
$page_list->filterByCollectionTypeHandle($type);
$template_pages = $page_list->get();
$return_data = array();
foreach ($template_pages as $template_page) {
@eklect
eklect / c5-get-url-custom-page.php
Last active August 29, 2015 14:16
Concrete 5.6 → Get Page URL with Loader Navigation
<?php
$nav = Loader::helper('navigation');
$page = Page::getByPath('/about-us'); OR $page = Page::getByID($page_id_here);
$url = $nav->getCollectionURL($page);
//BONUS breadcrumbs :)
$breadcrumbs = $nav->getTrailToCollection($page);
?>
@eklect
eklect / c5-last-id-database.php
Last active August 29, 2015 14:16
Concrete 5.6 → Getting last insert ID from Database
<?php
global $u;
$db = Loader::db();
$a = "INSERT INTO exampleTable(uID,completed) VALUES('$u->uID','false')";
$b = $db->query($a);
$c = $db->insert_ID();
?>
@eklect
eklect / c5-get-http-url.php
Last active August 29, 2015 14:16
Concrete 5.6 → Get the http:// URL for concrete 5 page
<?php
//Get Send Update URL
$wanted_page = Page::getByPath('/path/goes/here');
$url_helper = Loader::helper('navigation');
print_r($url_helper->getCollectionURL($wanted_page));
?>
@eklect
eklect / c5-get-block-url.php
Last active August 29, 2015 14:16
Concrete 5.6→ Get Block URL from Controller
<?php
//In The View
$this->getBlockURL();
?>
@eklect
eklect / c5-get-relative-url-for-block.php
Last active August 29, 2015 14:16
Concrete 5.6 → To Get Block Relative URl
<?php
$bv = new BlockView();
$bv->setBlockObject($this->getBlockObject());
$blockURL = $bv->getBlockURL();
?>
@eklect
eklect / c5-load-file-list-from-fm.php
Last active August 29, 2015 14:16
Concrete 5.6→ Loading File List from File Manager
<?php
Loader::model('file_list');
$fl = new FileList();
?>
@eklect
eklect / bootstrap-single-button-dropdown.html
Created March 10, 2015 15:26
Bootstrap 3 → Creating a single button dropdown
<!-- Single button -->
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
Action <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
@eklect
eklect / c5-proper-field-var.xml
Last active August 29, 2015 14:17
c5 → Proper Way to add field variable into db.xml
<field name="columnNameHere" type="C" size="255"/>
//If you forget to add the size property, c5 will fail to update the DB table
@eklect
eklect / c5-on-start.php
Last active August 29, 2015 14:17
c5 → Event Functions in Controller
<?php
//Use this function inside your controller to have it fire when you load the block.
//You can call any method inside the class, including action methods
public function on_start(){}
//This function fires when the view is rendered
//Use this function when you want to pass controller variables to the view
public function view(){}