One of the most common mistakes in "tweeking" your new concrete5 site, is to incorrectly modify a package or block css.
concrete5 has made a super easy way to handle this out of the box.
Before we dive into styling a block, we need to cover two topics that are related to what we are doing. The concrete5 directory structure and the block file structure.
The concrete5 File Structure
One of the first questions concrete5 noobs ask when installing it is "why are the exact same folders in the concrete folder, and then also in the root folder?".
The concrete5 file structure is designed to offer total flexibility on how you style and expand your site, and still maintain easy updatability without overwriting all your hard work.
A single page would be a great example. You can actually just create a new "login.php" file and drop that into your root "single_pages" folder, and bam...your new page is enacted on the site, and you are in no danger of overwriting it when you update.
The concrete5 Block Structure
There is a lot that can go on in a block file structure. But lets just cover the basics.
The bare-min required files are as such: db.xml (for versioning), view.php, add.php, edit.php , and controller.php.
Various developers may include all kinds of other file types, folders, templates...ect. But what you want to hone in on when wanting to make some aesthetic changes to a given block, is any file with the prefix "view". That, in most cases, will be view.php and view.css. You may also see a view.js.
Adding Page Owner Information
Lets do a quick example of how to create a custom content block template, and add some page owner information to be shown along with that content post.
First, if you haven't read my last article on working with user vars and displaying them on the front end, you may want to read that here: http://stratisdesign.com/stratisdesign/blog/programming/hello-user-with-c5-user-vars/
Create your new template folder structure
This is where the magic happens.
Going back earlier in this article, we want to avoid at all cost modifying in any way the existing content block if we can help it. Again, were we to do this, as soon as we update our core install, we would lose our modifications.
The Core content block can be found in ROOT->concrete->blocks->content
First, we are going to take advantage of the duplicated folder structure in the ROOT of your install and use the blank blocks folder. Lets create the following folders:
ROOT->blocks->content->templates->owner_vars
So we created a folder for the content block, a folder for templates related to it, and lastly a folder that represents the name of your custom view. In this case, I am naming this view "owner_vars", which is translated automatically in the custom view list in the front end as "Owner Vars".
Second, copy the view.php, view.css, and/or view.js from the core content block folder, and then paste those into your new owner_vars folder.
Technically, you now have a new view ready to go! That's it!
But we are going to take this a step further and add some stuff to our new view.
Adding some owner vars
Lets presume that you read through my last tutorial and know how to go add a custom user var in the backend. If you wanted to, you could add other user vars and associate them to collections/pages. But for now, we are going to focus on just the avatar and the owner info to be added to the top or bottom of our content item.
So lets edit that view.php file within our new owner_vars template of our content block.
Things are a little different in how you approach grabbing your user info within page versioning than simply using the $user object.
We will still use the UserInfo method, but first, we need to grab the author user ID so that we know who we are looking for other than the currently viewing user.
To do this, we will need to call on some globally loading "knowns" that load with every page, however, not the easiest to understand and work with. I will do my best ;-)
First, we load in the page collection as a globally accessible var "$c".
$c = Page::getCurrentPage();
Next, we are going to snag the user author ID from the collection page object. This is a built in function within the page model. If you scan through that file (ROOT->concrete->models->page.php) you can see all the functions and what they need as inputs that can be called on the $c (collection) object.
$uID = $c->getCollectionUserID();
Now we are going to grab our UserInfo object so that we can snag the avatar.
$ui = UserInfo::getByID($uID);
Next we load the avatar helper.
$av=Loader::helper('concrete/avatar');
And last, print out our vars with an if statement on the avatar so that we don't blow up our page if the user does not have one. And then also, a simple call to the uName var from the UserInfo object.
if($ui->hasAvatar()){
echo '<img src="'.$av->getImagePath($ui,false).'" alt="" />';
}
echo $ui->getUserName();
Now, it may be advisable(depends on your server) to add your global "BASE_URL" and even append that with the global "DIR_REL" vars in front of the getImagePath if your site is within a sub directory like so:
if($ui->hasAvatar()){
echo '<img src="'.BASE_URL. DIR_REL.$av->getImagePath($ui,false).'" alt="" />';
}
echo $ui->getUserName();
All done!
So there you go. You created a new view of the content block, and you added some author info in front of or after the content within that view.
And the best part is...you are hassle free when updating your core install!
- Replace the default font in the Elemental theme
- Making Elemental themes image slider title and description responsive
- Add a Font Face kit
- Creating a Full screen Header Image for the Anitya Theme
- How to add Orders to Razor Commerce Programmatically
- Add new entries to the "Social Links" Dashboard page
- Demo Page for Dashboard Addon
- How to create modal dialogs on dashboard single pages in packages
- Record the page ID in form responses
- Get an addon or theme ready for the marketplace
- Logical OR filtering for multi select attributes
- How to copy the Elemental theme to use as a base for new themes
- Get block path from block controller
- Make all YouTube embeds responsive
- File Permission Errors: How to spot and fix these errors in Linux
- Global Areas for each language section
- Use Bootstrap Tabs in frontend theme without an add-on
- Package Install Notes
- Get ecommerce product name and description for use in custom blocks
- Getting the URL for a block or package tool
- Process to know logged in user from block
- Third party assets in packages
- How to check if you are in edit mode or not
- Using a Custom URL Attribute for External Redirection
- Windows IIS7 Pretty URL
- Missing and hard to find pages on concrete5.org
- Programmatically testing permissions on pages for a given user/group
- Speed up redirect for Internationalization add on
- Add rel="nofollow" to your pagination links
- Protect File Url's : Part 1
- Magic Data Page List Teaser functionality for Page List Plus
- Protect File Url's : Part 2
- Create large numbers of page versions for testing
- Load template specific assets
- Get the Package Path in a Dashboard Single Page Controller
- Internationalization Add-on and a Home page for every language!
- Responsive Video Embed
- Extending Area Model and Deleting Areas
- My site isn't sending email!
- Changing parent page, & keeping old child URL's active
- Easily scope CSS using LESS or SASS
- How to run multiple concrete5 installs on a single core (Apache vhost config)
- What version of concrete5 am I using?
- Check prerequisites before installing a package
- Hardcode edit permissions for areas
- Multilingual in combination with a tools file within a package
- Inherit between blocks in the same package
- Reverse Stack Content Display Order
- Make a package update automatically available
- How to use the Interactive Shell to run code against concrete5 from a console
- How to Extract Blocks from a Stack and Randomly Display Them
- Low profile caching method
- Delete Multiple pages
- Programtically Give a Group "Access User Search" Permission
- Reliable package install & updates
- Magic Data Enabling a Page List
- Programmatically creating and adding users to Groups
- Use tokens to secure transactions
- Filtering a list of states based on selected country
- Write a Queueable Job in concrete5 5.6.2+
- Overriding profile pages from within a package
- Style a file input field
- Overriding single pages within a package theme
- Integrate Concrete Wall with Magic Data using Universal Content Puller
- Access virtual hosts from any device using xip.io
- Concrete 5 in an AWS load balanced cluster
- Sort out file permissions in bulk
- nginx (with fastcgi_cache) + php5-fpm
- How to add composer functionality to your custom block
- Concrete 5 in an AWS load balanced cluster - 2
- Search block without results
- Separating environment specific configurations
- Styling the pagination
- Save and retrieve arrays of data
- Formatting numbers
- Send administrators to the dashboard upon login
- Add tracking code to page headers sitewide, or on just one page
- MyISAM Vs InnoDB
- Prevent an HTML block from interfering with edit mode.
- Format an edit mode marker
- Check If Block is Being Displayed in the Stack Dashboard Edit Page
- Core-Commerce Product pagination bunched up together
- Programmatically setting advanced permissions
- Organise your concrete5 web space for risk free upgrades
- Adding the Page Name to HTML Markup as an ID
- Display number of page views count
- Change Locale with PHP
- Translation of some special items
- Grant Dashboard access to specific groups
- Obtain a Unique Identifier for a Block
- Display User Attribute as Full Name, Image, and a Custom Link on every Blog Post
- Adapt jQuery event handlers to old concrete5 versions
- Edit the e-mail sent by form block
- 10 Useful Tools You Probably Didn't Know Existed, Volume 3
- Forbidden Functions
- Install C5 using MySQL InnoDB tables
- The block does not work!
- Allow HTML5 tags in TinyMCE
- Internationalization and the t() functions family
- Integrate Magic Data with Avatar add-on, and Facebook social plugins
- Translate your package
- Overriding Guestbook Entry Order in 5.6+
- Cope with old versions of Internet Explorer
- Integrate Magic Data and Page Attributes to display different images in areas or pages.
- Very Simple concrete5 theme
- Profiling your concrete5 site with Xdebug and WinCacheGrind
- Skip the file manager for specific set uploads
- Integrating Magic Data Tokens with other blocks
- Exclude Admin / Super user from user list
- Scripting Your Site Into Maintenance Mode
- Subvert the JavaScript run by the Page Selector helper
- Extend Core Statistic system
- Flushing your own cache
- BackPorting to older c5 version
- Copy a Language Tree in Concrete5
- Choosing what c5 version to develop for
- Use attributes to set background images
- Grant Access Only to Files Users Have Uploaded Themselves
- Converting JSON to an array
- Common Theme Pitfalls
- Overriding Core Files and Extending Core Classes in concrete5.6 and later
- Email user when their account has been activated
- Change Filtered Words in URL Slugs
- Using concrete5 from PHP CLI
- Set Up a Demo Server
- Share dashboard sections between addons
- Using core bootstrap tooltip at your front-end
- Add a mailbox (PM) preview to user profiles
- Hide a newly added page
- Default values in db.xml
- Performance improvements in concrete5 5.6.1
- Let's get Recursive ! [Solving Page Recursion Issues]
- .htaccess snippet
- Show content in more than one place
- Make Responsive Tables
- Creating a Fresh Foundation 4 Theme for concrete5
- Compress JS, and CSS files
- Add dir="rtl" to for a specific subddirectory
- View All products link in e-commerce product list
- Decrease size of your c5 install by removing some unnecessary files
- Restore an internal page type used by the concrete5 core
- concrete5 php debug clips
- Troubleshoot red "1" error upon marketplace package upgrade
- Fix missing 'Upload' button and setting up allowed file types.
- Recovering a lost password without "Forgotten Password"
- Replace Email Body
- Basic SEO
- How to use Bootstrap Tabs in concrete5 dashboard
- Using a SSL proxy with Concrete5
- Faded CSS3 Menu
- Visualise Bootstrap column widths
- Create a split scale slider for greater range.
- .html or .htm file endings for pages
- Basic .htaccess configuration, Setting custom site theme paths , and robots.txt with concrete5
- Main + Sub Navigation with Selected Trail in Multi Language site
- How to hide all child pages under a parent page in autonav
- Change how a block looks : templates
- Avatar Edit information for your user - very basic
- Troubleshooting concrete5 core upgrade: database and core versions
- [French] Afficher une liste aléatoire de pages
- How to create a product page after choosing "Skip Page Creation" eCommerce
- [french] Afficher les résultats de la recherche sur une autre page
- Adding your own 'Page Type' to your theme
- [french] Créer une splash page (page d'entrée)
- Installing Concrete5 on WAMP (Windows) Local Server
- BitNami C5 Stack local to Windows Host Online - Database Table Name Sensitivity - Rename Tables Fix
- Setting Discussion Forums Category Order via Creation Date
- Using ZURB's Foundation Framework 3 with Concrete5
- Add dashboard icons to single pages in concrete5.6
- Set Site Email Default From Address
- Force HTTPS for Entire Website.
- Use query string path parts in a single page
- Superfish IE7 Submenu Gap & Hover Problem Fixes
- Transitioning from Joomla! to concrete5
- Review address on the final step of checkout
- Delete a Project Page
- Modify a packaged theme
- Some tricks for debugging JavaScript
- 10 Useful Tools You Probably Didn't Know Existed, Volume 2
- Page List Active Link
- Using Custom Attribute and Page Type
- Make your own simple custom navigation menu
- Customize PayPal order details to show shipping & sales tax
- Attach jQuery event handlers
- SEO and concrete5
- Manually upgrade concrete5
- Display simple eCommerce cart details
- MySQL database case insensitivity
- Cache ADOdb Active Record Metadata
- Make your layouts responsive with native c5 layout tool.
- How to make Google's mod_pagespeed work with concrete5
- How To Turn Off Sales Tax By User Group in eCommerce
- Create a searchable, extensible page selector attribute
- concrete5 for Drupal Designers and Developers: Page Building Features Compared
- Improve rendering of jQuery plugins
- Concrete 5.5 Editor/Client Tutorials for absolute beginners
- Increase your PHP memory limit
- How to show the blocks of an area in a random order
- How to Convert a Site to concrete5 and Recreate Original Page Paths for Search Engine Recognition/Optmization
- Multi-Site Concrete5 Installation for GoDaddy Shared Hosting
- Protect a jQuery plugin from colliding with files from other add-on packages
- Installing Concrete5 on a MAMP local server
- Translating Site Specific Texts
- concrete5 Add-On Developers: Create Your Own Demo (5.5.0 and Up)
- Create a News system using Composer
- Install concrete5 from the Command Line
- Get marketplace submissions through the PRB
- Generate a .mo file with .po file from mygengo with poEdit
- Page stuck in edit mode?
- External Oracle database connection
- Transfer a project to a new owner
- concrete5 5.5 Content Import Format, Sample Content & Starting Points
- Use the Config table for configuration data
- Use IRC to connect with developers, editors and designers from everywhere
- How to change the Rich-Text-Editor Interface
- Override Site Search Block to Search Through eCommerce Product Titles Only and Return Only Products
- How to Add a Favicon or Apple iPhone Thumbnail in Concrete5.5
- Hide the subdirectory URL
- Restore a login page from the trash
- How to fix a broken uploader on a new installation
- Update Very Old Sites
- Add ability in contact form to reply to the submitter
- 5.5 (and later) User Interface and Twitter Bootstrap
- Getting Help on Forums
- How to display images with RSS displayer
- Absolute Basic Web Stuff
- concrete5 5.5 Stacks vs. Scrapbooks
- Email 'from' field populated using the senders email address
- Setting Up and Using Concrete5's Composer Feature
- Responsive Images – Web Design with Device Optimized Images
- How to add a vanilla forum to your c5 site.
- How to hide tracking code for editable users (post 5.5.x)
- Use tabs in an edit form or dialog
- Download and manually install an add-on
- Creating a single page to handle both Login & Registration
- Make ALL Your YouTube & Other Embedded Videos Auto-Fit
- Add a slider control to an edit menu or form
- Handle Sessions From The DB
- How To Add a Custom @Font-Face to Your Theme
- Customize a core theme
- Validate form inputs in the browser
- Configure additional cache settings via Zend Cache options
- Create a form with a dynamic list of input elements
- Concrete5 and Godaddy shared linux hosting plan - Complete solution
- Making a theme from start to finish
- How concrete5 Events work
- AJAX Lessons
- Sort a list with drag and drop.
- Native Multi-Site Support
- Remove Site Name from your web page header
- Sort an HTML table using jQuery
- concrete5 5.5 White Labelling Support
- Pulling In Sub-pages from Multiple Paths
- Change the format of your site's page titles
- 10 Useful Tools You Probably Didn't Know Existed, Volume 1
- Log user search terms
- Show messages from JavaScript as C5 error messages.
- Facebook's opengraph and concrete 5
- Backup a database
- Special Offers in the Marketplace
- Speed Up Databse Queries with the ADOdb Compiled PHP Extension
- Add a second email field to user registration form
- Change Things Without Hurting Anything : Overrides
- Upgrade - Add another block type or single page to an installed package
- Fix character encoding in your database
- Theming System Single Pages like Login, Register, etc
- Set the Time Zone of your Concrete5 Installation
- Using pretty URLs with hosting on Heart Internet
- Assign a license to a project
- Connecting to an external database other than MySQL
- Concrete 5 Tutorial Vidoes
- Controlling the use of Google Web Fonts through Page Attributes
- Can't Connect to the Community
- How to uninstall add-ons
- [French] Faire du multisite avec Concrete5
- A Mobile Approach in Concrete5
- Transfer an add-on license to a new project
- How to programmatically add comments to a guestbook block
- Manually set up the basic blog (if you didn't include "sample content" when installing your site)
- Running many concrete5 sites
- How to parse the requested path
- Enable Pretty URLs in Windows IIS
- Speed up Concrete5 with Minify and BootstrapCache
- Modifying the default Paging display in Concrete5
- Creating an accordion page
- Install Concrete5 "invisible" over an existing website
- Automatic Email Obfuscation
- Using CloudFlare
- How to Install PageTypes with Custom Attributes assigned By default from a package
- Dynamically concatenate, minify, gzip, and server side cache multiple LESS and CSS files in your theme.
- Security and concrete5
- Disable the cart overlay in eCommerce 2.0.x
- Using a custom callback with the Page Selector
- How to include a tracking code for non-admins only
- Fix block edit error on upgrade from 5.3.3.1 to 5.4.0
- How to move a site from 1 directory on a server to a new directory on the server.
- Add licenses from multiple user accounts to a single project
- How to add the Google +1 button to a site
- Reinstall A Lost Core Block Type
- Project Ownership
- Use Google Web Fonts on your web site
- Get Email Notifications of Site Changes
- Arranging Content
- How to translate a Concrete5's package in your language
- Troubleshoot Mail Problems
- In-context Editing
- Custom Attribute Types
- Clean up copy pasted from MS Word
- Disable the Dashboard Statistics graph (and stats collection)
- Guestbook Closed Comments
- Edit or remove your site name
- A Multi-Site Approach in Concrete5
- How to include files in search results
- Create a Citation Block For Your Site
- Create menu-placeholders in the auto-nav
- How to Make an Easy Dropdown Menu
- Adding the noindex meta tag
- concrete5 and GoDaddy Shared Hosting
- Adding a Jquery Accordion Menu
- Restore a deleted system page (like Login, Members, etc)
- Packaging up a Theme
- Using File Manager Sets
- Use Layouts to Position and Align Content
- File Manager: Tools and Features
- Strategies for Creating Custom Site Themes from an Existing Design
- Add (or change) your site's Favicon
- Use Special eCommerce User Attributes
- Set Up eCommerce and Digital Downloads
- Set Permissions of Specific Areas and Blocks
- Build Out a Site From a Comp
- Using Advanced Permissions
- Monitor Your Site's Traffic
- How to round corners on user's avatars
- How to run certain Jobs via cron
- Backup and Restore File Permissions In Linux
- Explain all these different logins I have!?!
- Using Google Apps for Your Outgoing Mail
- Make Your Site Accessible to Administrators While in Maintenance Mode
- Extend the Rich-Text Editor
- Customizing Superfish
- Migrating from Development to Live Server on Fedora: Step by Step
- Get Pretty URLs working on Dreamhost
- Adding a Facebook Like Box to your concrete5 Website
- Share Content Across Multiple Pages
- Five easy ways to speed a concrete5 Site
- Change Allowed File Upload Types
- Developers Introduction with Derek Allard
- Get the Content Editor's Text and Background Colors to Match Your Theme
- Adding F4V Support to the Basic Video Player Block 2
- Restore the "Generate Sitemap" Job
- Your site's URL
- Disable the Dashboard Statistics Graph
- Reconnect To The Community
- How Can I Edit Page Defaults?
- Setup a subdomain based demo server
- Change Block View Behavior With Templates AKA: Make Anything Fancy
- Setting Up and Maintaining a Centralized concrete5 Installation
- How do I remove the "Powered by concrete5" in my theme's footer?
- Increase Upload Size
- Why do I need view.php in my theme?
- Hardcode a Block into a Page Type
- How do I add a bookmark icon (aka favicon) to my site?
- Running Multiple concrete5 Instances Using a Single Core on a Redhat enviroment
- How do I add Google Analytics tracking code to my site?
- Centralizing Templates/Blocks & Language files
- I can't login!
- Styling the Page List Block
- Stop Themes From Interfering with The edit bar
- How do I exclude a specific page from sitemap.xml? How do I set priority?
- Running Multiple concrete5 Instances Using a Single Core on a Plesk-Managed Web Host
- Mail on Yahoo Hosting
- Create an RSS feed from your site
- File Block: Display File Type Icon next to the Download Link
- Integrate Google site search into concrete5
- Adding Sitemap and File Manager Quick Links to Edit Bar
- SEO Tip: Redirect All Page Paths to One Ending with No Slash
- Converting a site into a theme
- Another Primer on Areas and Page Types
- "concrete-ize" a basic HTML theme in 8 minutes
- Built-In Attribute Reference/Cheat Sheet
- Building an iPhone-Optimized Version of a concrete5 Theme
- Building Sites in Multiple Languages
- Combining Views, Controllers, Events and Models to Create a Example Shopping Cart
- Automatically Expire Pages from a Page List at a Certain Time
- Make a new Custom Attribute Type
- New Cheat Sheet Documentation Launched
- Creating a New Block Type
- Custom Footer Menus using Auto-Nav
- Customize a Block's Appearance
- Creating and Working with db.xml Files
- How-To: Build a Single-Page Powered Editing Interface for concrete5 Pages
- Basic MVC in concrete5
- Primer: Auto-Nav Block
- Hello User Block Example
- JavaScript, jQuery and concrete5
- Custom Block Templates/Views
- concrete5 Add-On Developers: Create Your Own concrete5 Demo (5.4.2.2 and earlier)
- Screencast: How to Create a Client Area
- How to Fix Strict Standards Error
- Hacking core eCommerce for php7 and c5.6.4