PyroCMS Theme Development

Over the last few days, when time has allowed, I have slowly converted a sites design over to a PyroCMS theme.What I’ve done so far has been pretty easy and I found myself wondering why others haven’t done this.

So far here’s what I’ve done.  I viewed the source of the site I wanted to convert and copy and pasted it over to the appropriate folder for my theme in my PyroCMS install (there’s a bit more to setting up a theme, and I’ll cover that in another post).  Once I’d done that I could view the content on the site.  But it wasn’t styled, so I pulled over my styles and then took a peak.  Looked better, but there were a few pieces of navigation that was missing.  It took me a bit of time to figure this out, but eventually I did.  It was because those pieces of navigation had an image element in them.  In this case I was able to replace the image element with a solid color.  If you are going to have an image element in a style, the best way I believe to do this is to put it in your header.  The reason I say this is two fold.

  • CSS files are not parsed by PHP
  • In order to get the image to show up, from your CSS, you’d have to hard code the path in your CSS file which would cause an endless amounts of nightmares because themes can be installed in one of two places (well technically three)

At this point I started taking apart the default.html file that I’d copied over and creating partials.  If you’re familiar with how PHP includes you’ll be right at home with the partials. Even if you aren’t it won’t take you very long to pick them up.

Lastly a couple of other notes about putting together a theme.

  • For your items that are going to be in the header of your site and exist throughout the site use the asset tag.  As I understand it when the theme is in production the asset tag will minify the CSS (hopefully decreasing the load time if the site)
  • For images that are crucial to the site and you’ll be bundling with the theme use the theme tag.  Seems pretty obvious now, but for awhile I was trying to use the asset tag and it wasn’t going to work.

Happy Coding.

PyroCMS Addon Hierarchy

I’ve been spending a bit of time in PyroCMS the last couple of days trying to wrap my head around some of the things that it does and thought what I discover might benefit some others who are trying to get into PyroCMS.  So here we go.  I should note that some of this you’ll find in the documentation, but some of it are things that I’ve written down to help myself better understand what’s going on. Lastly this is a very generic overview.

Plugins

While this is the most basic of addon’s it can also be pretty powerful.  When I initially started writing this I was going to say that this was best used for regurgitating text.  And then I looked at some of the core plugins and boy was I wrong!  There’s some pretty large plugins!  Additionally plugins work with modules that you might write. There are some limitations to plugins, but with the right person it is pretty powerful.  I would say plugins are best if you are accessing data that is already on the site in some aspect.  So if there’s something in the database you need to extract this can do it.  Combined with a module a plugin can do quite a bit!

From a users, no developers,aspect, plugins, if documented well, will allow your users to do a great deal with it’s tagging mechanism.

Widgets

Widgets are the next step up from plugins.  They exist in the control panel interface and can be dragged and dropped onto web site sections (these are created in your templates).  They usually do a very specific thing and the display is written by the developer who made that widget. So in some aspects they are a bit more rigid, but can do some pretty powerful things.  Users I think will find them a bit easier to use than plugin tags, but are limited by the users creating the widget.

Modules

The grand daddy of them all!  Modules are installed in the control panel interface and allow you to do a wide variety of things.  If you are coming from a WordPress background they are plugins.  Not your simple do one thing plugin, but a plugin that’s been taking HGH and other sterioids!! They are big and at first, for a new developers aspect, might seem a bit unwieldy, but once you get into them you’ll realize the power that they can wield!  On the back end of things a module will allow you to have an interface were data can be changed.  So if you wrote a module that kept track of baseball standings or something like that you could have a backend interface that a user would be able to access and edit that information.  As I mentioned above plugins work with modules.  This is one of the ways that content is displayed on the front end.  Another way that content is displayed on the front end is through a controller and turning that on in your module setup. As I’ve not completed a module, yet, I suspect that there are some other things that I might have missed on this so, what is here is what I’ve learned so far.

Happy developing for PyroCMS!

Contributing to PyroCMS

I’ll be the first to admit I’m a noob when it comes to using Git.  As a one man developer I didn’t really think there was any use for it so I didn’t use it. And then I did, and then I quit.  And now I’m back to using it.  Despite my using it I’m still a noob.  So when I wanted to add to the PyroCMS documentation I was kind of in a quandary.  I could fork it pretty easily, that’s built into GitHub, but then how did I get it to my system so I could add and edit the files?  Here’s what I did and so far it seems to be working.

This post on GitHub explains forking and pulling (actually cloning) a copy onto your local system.

A couple of things to keep in mind.

  • Doing a push to your forked version is different.  You’ll want to push origin to 2.2.  For example: git push origin 2.2 rather than git push origin master
  • If you don’t use GitHub for your Git development (I use bitbucket.org) don’t worry about it. When you do your push it will ask you for your GitHub Username and password.  

Other than that get contributing to PyroCMS!!  At this point I won’t be contributing to the core itself. I’ll be trying to help out on the Docs side of things!

PyroCMS Module creation checklist

I’ve been working on a PyroCMS module for a project at work and I got to say at times it’s been the biggest pain in the ass, and at other times totally rewarding.  The frustration part is putting together the details.php file.  The details.php is key and it’s got some awesome features to it, but the module tutorial (here) leaves out some very important things I’ve learned.  To that end I’m hoping that this post will help me as I go forward and help other’s that might run into similar issues. If you don’t see something up here that you’ve ran into put it up…please!

  • If you are trying to get the ‘shortcuts’ to work for your module, you need to let your admin controller know what it should show.  See this forum post.  
  • Can’t get your language file to be read?  Make sure that you are loading it in your controller (this one had me stumped for a long time)

 

This information is current as of 3/19/2013 and pyrocms version 2.2.  Going forward this information maybe invalid.  

Wading into PyroCMS

I’ve decided…I’ll be wading into some PyroCMS development and other PyroCMS things.  This is kind of a follow up on my previous post where I talked a little bit about PyroCMS, WordPress and ExpressionEngine.  In the end, for me, it came down to Expression Engine and PyroCMS.  After Phil kindly left his thoughts on PyroCMS I did some more thinking and research.  I’m not sure if this is the direction that my place of employment might go, but I’ll be an advocate of going this direction.

So why the change?  It really came down to this.  I was once again reading a WordPress plugin tutorial and trying my hardest to write a plugin for an upcoming site we have at work.  It was a better tutorial than what I found in the past and I had high hopes of knocking it out of the park.  But it just wasn’t making any sense.  I felt as if I needed to know everything about modules and widgets before I would have been able to get something up and running (never mind the parse order…maybe I didn’t need to know that!).  I’m up for a challenge and all of that, but this made no sense to me.  So I dropped that, picked up the PyroCMS manual and began my module development.  In less than 2 hours I had more than what I had on WordPress.  So that’s why I will be going in the direction of PyroCMS with my development.

It doesn’t mean this site/blog will be switching to Pyro anytime soon.  Pyro is a web development platform and WordPress is a blog platform.  Although WordPress tries to act like a web development platform, and there are many who make a great deal more money than I do, doing that, it’s a pain.  Pyro isn’t a blog platform and from the little I’ve used it as a blog, it needs some help (this site was originally on Pyro).  Maybe I’ll help with that.

I’ve got a lot of learning to do with PyroCMS, but in the end I think it will be for the better.  Hopefully I’ll be able to contribute in some fashion.  I doubt that it will be to the core product.  I suspect my biggest impact would be elsewhere (documentation or tutorials perhaps).

 

Movie Review: Trollhunter


This movie, Trollhunter, was recommended to me by someone that I work with.  He and I enjoy movies, but he looks at movies a bit differently than I do so I was a bit skeptical, but since it was on Netflix I figured I had nothing to lose other than a couple of hours at the most (for what it’s worth my criteria for watching a movie is Entertain Me! Not to say that I don’t watch documentaries, but I want to be entertained most of the time).

So I sat down and watched Trollhunter.  I honestly figured that I’d turn it off after 20 minutes or so.  This film is in the likes of The Blair Witch project, a movie which my wife and I walked out of, but I was fairly quickly sucked into the story.  It’s the story of three college kids who are, for some reason, filming a ‘poacher’ who they think keeps killing bears.  Apparently in Norway there are few bears and fewer people allowed to hunt bears so a poacher is not very well thought of.  These three college students start to follow the supposed ‘poacher’ and find that he’s not a poacher but a trollhunter! From there they begin to follow him and get into the main story.  I’ll leave things at that!

It’s a foreign film and has sub-titles throughout the whole thing, but unlike some other sub-titled films I didn’t really notice is because the story was put together well.  It’s not an action packed film, but there is just enough to keep you wanting more.  I’d recommend watching this if you are looking for something a bit different.  I should also mention that Tremors is currently on Netflix streaming as well.  I was going to try a doubleheader but didn’t make it!

Great starter, bad finisher!

For the few people who may read this, or who don’t, you know that this week has been kind of an off week in regards to posting.  As I mentioned in a previous post I try and post on Tuesday, Thursday and Saturday.  The only day this happened this last week was Thursday.  It was a busier week, but there was no reason I couldn’t have posted something on Tuesday and Saturday.  Writers block was just an easy excuse, but it leads to something I’ve observed about myself.

In my personal life I’m a great starter of things and a not so great finisher.  When it comes to work related things I get them done.  I know why there’s a bit of a difference between the two, but if I take that out of the equation I’m still a bad finisher on personal projects.  One of my goals/resolutions/whatever you want to call it for this year, was to finish a couple of my projects and not start any until those were finished.  I haven’t finished them yet, and one of them I’m not 100% sure I will.  Not that there’s a lack of desire to finish it, it possibly has other consequences I’m not ready to address at this point. But there is another one I could finish.  I still plan on finishing it, it’s just getting down to business and avoiding distraction to get it finished.  Lastly if I find a project is not enjoyable, these are after all projects I take on in my limited personal time, I don’t want to address them.  Most of the time I do find them enjoyable, but when I hit something that is giving me a spot of trouble, I find something that is more interesting or that I can more easily overcome. Anyone else find themselves in this position?

I’m not sure that I have a solution other than forcing myself to get them done.  I also think finishing up a few shorter term projects will help with that satisfaction one gets from finishing something.  I’m on week 2 of a 4 week exercise program that come hell or high water I will be finishing.  Normally I’d get to about week 3 and be done with it.  So I’m on the look out for that ‘boredom’ and will just have to push through no matter what.

I’d be curious to hear what others have to say about this situation.  Do you find yourself starting stuff and not finishing it?

SQL Schema to CodeIgniter DBForge

11/2/2013 – Awhile back I got a comment from someone asking me about my MySQL to CodeIgniter DBForge stuff. I’m not really sure what happened, but I felt bad about not being able to help this person. So I finally got off of my duff and I added it to github.  If you want the code you can find it here: MySQL to CodeIgniter DBForge  If you do end up using the code for something, anything, let me know. I’d love to see what people can or will do with it.  

It’s fairly easy, in my humble opinion, to move an existing website that is not in CodeIgniter over to CodeIgniter.  However one of the topics that people, such as myself, may have never known about is the migrations option.  If you don’t know about migrations it’s worth your time to read up on them (you should also read up on Database Forge as that’s where the bulk of the work takes place!). I’ll try my best to sum it up for you.  Basically it allows you to make incremental changes to your database.  So if you need to add an active/inactive field to one of your tables you can make a migration. This may not sound like a big deal but here’s what it becomes a big deal.  If you bring another member on your staff and they’ve got a development environment and you’ve been making changes directly to the database how are they going to know when the database has been changed and they need to update their database?  That’s where migrations are the most powerful.  I’d add to this that it allows you the ability to quickly move your site from one host to another as the migrations are automatically ran.  The one caveat to this is that it does not pre-populate the data, so be aware of that.  So go do yourself a favor and read through migrations and dbforge.  I’ll wait here for you.

If your first thought was “OMG…that’s a lot of code writing to be done when I’ve already got the SQL Schema”, I’m there with you. But I’ve got a solution cause I have a TON of SQL code already written that was never going to end up in migrations with dbforge.  Just wasn’t going to happen.  However my handy little script has made this a non-issue.

So click on over to my SQL Schema to CodeIgniter DBForge page and get to converting your databases.  It’s currently in alpha and has only really been tested using phpMyAdmin and MySQL, so I don’t know how it works with other databases (like anyone uses anything else..J/K!).

Basically what you need to do is this. Go into your phpMyAdmin interface and click on the table you want to convert.  Once your in that table click on export (see image below)

PhpMyAdmin-Table-Export

 

Once you are in the export menu, you need to change a couple of options to just get the SQL Schema and not the whole database.  You want to click on “Custom – display all possible options” This will give you a lot of other options.  Under Output check “View output as text“.  Lastly under Format-specific options click on structure underneath Dump Table.  After that just click on the Go button and it will produce something like below.

PhpMyAdmin->Table->Export->Result

 

The highlighted area is what you need to copy and then paste into my migration interface! It will return you the CodeIgniter code that you can insert into your migration script (it doesn’t provide all of the information I should note.  You will need to create the base class and the downgrade path).

$this->dbforge->add_field("agentid varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT ''");
$this->dbforge->add_field("officeid int(10) unsigned NOT NULL DEFAULT '0'");
$this->dbforge->add_field("firstname varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT ''");
$this->dbforge->add_field("lastname varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT ''");
$this->dbforge->add_field("agenttitle varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL");
$this->dbforge->add_field("phone1 varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL");
$this->dbforge->add_field("phone2 varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL");
$this->dbforge->add_field("mobile varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL");
$this->dbforge->add_field("fax varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL");
$this->dbforge->add_field("email varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL");
$this->dbforge->add_field("url varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL");
$this->dbforge->add_field("location varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL");
$this->dbforge->add_field("information text CHARACTER SET utf8 COLLATE utf8_unicode_ci");
$this->dbforge->add_field("testimonials text CHARACTER SET utf8 COLLATE utf8_unicode_ci");
$this->dbforge->add_field("dirname varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL");
$this->dbforge->add_field("idx text CHARACTER SET utf8 COLLATE utf8_unicode_ci");
$this->dbforge->add_field("active char(1) NOT NULL DEFAULT 'y'");
$this->dbforge->add_key('agentid', TRUE);
$this->dbforge->add_key('officeid');
$this->dbforge->create_table('agents');

That’s it. I took one of my larger CodeIgniter installs and converted it over to migrations in about 30 minutes. Pretty slick huh? If you notice any problems or have any suggestions for improvements I’d love to hear them. Please comment here.

Happy migrating (and of course coding!)!

Business Idea: Improve the sales process

Not a week goes by that I don’t get at least 3 to 5 sales call of some sort.  Most of the time it’s something related to hardware, but other times it’s software.  And most of the time I end up hanging up on them as I’m not interested and I don’t have the money (which I really shouldn’t do I know!).  Obviously sales person X doesn’t know about sales person Y, but it’s just ridiculous the number of sales calls I get.  At least I feel that way.  A lot of these sales calls I’ve inherited, I think, from the previous two systems administrators/directors of IT. Regardless it’s got me thinking a bit about the sales cycle.  It’s got to be hard being a sales person. Whether they are calling me or not.  There has to be a better way in this day in age. The person that comes up with a better way for a sales person to get leads and a way for a director of IT to vet those calls/services will be a very rich person…I think!

Some random ideas I’ve thought about (these are just random thoughts and are not complete by any stretch).  What if there was a website where buyers could sign up.  They could put in what they have currently (hardware, software, office equipment etc), what types of products they are interested in buying in the next 12 months.  Sales people could then search through there for potential leads. The buyers could, would be encouraged, to put up a ‘bid’ when they are looking for something new.  As sales calls come into the buyer they can direct the sales person to this website and find out what the buyer is interested in.  I know this sounds like a social network, and I suppose it is to some extent.  If I were creating something like this I’d make sure that both parties were vested in some aspect. The buyer could not just send the sales people there and never check it. Sales people could not just start pitching to these people without any shown interest.  My hope would be that this would take out the cold calling aspect of the sales person. Calls would only happen if both parties are interested in proceeding forward.

Just an idea.  Perhaps there’s already something out there like this that I’m not aware of.  If there is leave a comment so I can check it out!