Community Forums › Forums › Archived Forums › Design Tips and Tricks › Insert Columns using a Hook and Responsive
Tagged: column classes, hooks, responsive
- This topic has 10 replies, 3 voices, and was last updated 10 years, 6 months ago by
Anita.
-
AuthorPosts
-
March 31, 2013 at 3:57 am #32217
Anita
KeymasterThere may be an occasion where I need to stick in several columns on all pages and posts. Would I be able to code the columns using Column Classes and then apply it once to a hook so that the columns show up on all pages and posts? Also, would the columns be responsive if I am using a responsive theme?
Love coffee, chocolate and my Bella!
March 31, 2013 at 5:00 am #32227Robert Neu
MemberThe short answer to this is yes. You could definitely do that. Bill Erickson outlines how to create a better, easier grid loop using column classes in this post: http://www.billerickson.net/a-better-and-easier-grid-loop/
What you're talking about is similar to what he's doing there. If the content that you wanted to include was static, it would be even easier to include. You'd just need to set up some conditional statements to include your content on the pages/sections that you wanted.
If you need some help figuring it out, let me know and I'll give you a hand.
March 31, 2013 at 5:06 am #32228Brad Dalton
ParticipantThanks for the hard question Anita!! hahaha
Maybe this code (forked from Bill Erickson) will help and i will try and modify it at some stage.
I am sure you can paste the HTML for content columns into the Simple hooks field to display content columns in any genesis_hook location so you must be able to add a conditional tag and use the code in a custom function also.
March 31, 2013 at 5:15 am #32229Anita
KeymasterThanks guys! This is wonderful. I will give both of these a try today on my demo site. If I have some trouble, I will post back here.
Love coffee, chocolate and my Bella!
March 31, 2013 at 5:49 am #32235Brad Dalton
ParticipantHere's the code i wrote which displays 2 content columns using the genesis_before_footer hook which you can change.
https://gist.github.com/braddalton/5280346
You can also add a conditional tag to this custom function.
March 31, 2013 at 6:02 am #32237Brad Dalton
ParticipantI changed the hook for this code so it displays before the post on single posts and archives.
I'll add the code to Github for single posts with a conditional tag so it doesn't display on archives shortly.
March 31, 2013 at 6:02 am #32238Anita
KeymasterSo Brad, in the last code you posted, I would just insert that in the functions or add that to the Hook area? Because the columns will have a lot of rows, i.e, 2 columns with 20 lines, 10 each column... I would hate to add that directly to the functions file.
Love coffee, chocolate and my Bella!
March 31, 2013 at 6:16 am #32239Brad Dalton
ParticipantThis code applies to the Genesis content columns code.
You'll need to add the CSS code for content column classes in your child themes style.css first. This code is a large block of CSS written by Brian Gardner. http://my.studiopress.com/tutorials/content-column-classes/
Then you can add the HTML for the columns in the code. It already has it for 2 columns.
I think what you'll need is to create a custom widget area and use the HTML for your tables in the text widget.
Or add the HTML between the content column divs where i have placed the sample text.
March 31, 2013 at 6:25 am #32240Anita
KeymasterI am familiar with the Content Column Classes. I am confused now Brad but all of your writings and options. I just want to create the columns using the content column classes and insert them so that they show up below the content on pages or posts. If I have 20 pages but want the same columns on all 20 pages - use a hook to only have to code the columns once. So which option would serve me better?
Love coffee, chocolate and my Bella!
March 31, 2013 at 6:56 am #32241Brad Dalton
ParticipantThere's more than one way to do this.
1. You can use the Simple Hooks plugin
2. Create a custom function as above.
3. Create a custom widget.
If you don't want to add a lot of code to functions.php, add it in a widget. It has to go somewhere.
Adding content columns using custom functions can conflict with other code in certain hook locations which is why i think its best to use a widget for the after post/page location.
March 31, 2013 at 8:07 am #32251Anita
KeymasterOk! Now your talking! I love talking these things out with you guys. It really challenges me to LEARN. So, looking at one of the themes that already has the "After Post Ad" or the "After Content Ad" widgets - I could actually start with those and add the columns in one of those.
Love coffee, chocolate and my Bella!
-
AuthorPosts
- The topic ‘Insert Columns using a Hook and Responsive’ is closed to new replies.