First off, Im well aware of this topic, but sadly I cannot seem to reply with questions to the original answer provider. Seems Stack Overflow only wants answers on these threads so I am stuck:
Multiple rows with jcarousel
Anyhow, my problem is related to Drupal and the use of the JCarousel module for my views. Im currently getting to the end-stage of my theme development. However, Im having a few problems with this, namely in getting a jcarousel like view style but with 2 rows instead of one. With the following jcarousel-view.tpl.php in my theme folder, I was able to somewhat get further:
<?php
/**
* #file jcarousel-view.tpl.php
* View template to display a list as a carousel.
*/
?>
<ul class="<?php print $jcarousel_classes; ?>">
<?php $i=0; $rows_number=2; //you can change the number of rows ?>
<?php foreach ($rows as $id => $row): ?>
<?php if($i%$rows_number==0) : ?>
<li class="<?php print $classes[$id]; ?>">
<?php endif; ?>
<?php print $row; ?>
<?php if($i%$rows_number==($rows_number-1)) : ?>
</li>
<?php endif; ?>
<?php $i++; ?>
<?php endforeach; ?>
<?php if($i%$rows_number!=0) : ?>
</li>
<?php endif; ?>
</ul>
Here is the end result: http://static.inky.ws/image/2302/image.jpg
As you can see, it group each set of fields for each item into a common column. So I cannot create a full border for each individual item. (See: http://static.inky.ws/image/2303/image.jpg for an example of what Im trying to achieve code-wise)
I can get a grid view but it means changing my view's style to use "Grid", which costs me from using jcarousel. Does anyone have any suggestions on how I can improve my code above? Im thinking that the unordered list markup might not be helping me any.
Please have a look at http://mywishez.com
All those images on front you see are displayed using jcarousel. You can confirm with firebug as well. I set the hight and set the number of items more than can be held in a row!
Related
I have a Franchise site that I am working on. We setup at least 15 locations, and the microsite is serving well except for the fact of adding custom elements to the individual franchise locations.
How do I edit an individual microsite without having to mess with the "Network Admin" theme editor?
The Franchisee wants a block to be changed on the homepage: 'home-template.php'
Is there a way I can add the editor to the microsites?
Also, is there a way I can edit the CSS for an individual microsite?
Thank you,
Kyle
P.S. If anyone requires more information, please leave a comment, and I'll edit this question immediately.
Edit:
Here is how the block in question is being loaded from the template:
<div class="col span_4_of_12">
<?php $posts = get_posts( "category_name=home_04" ); ?>
<?php if( $posts ) : ?>
<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
<div id="box-personal_svc_bg">
<div class="sq-label_box_gr">
<h1><a href="<?php the_permalink();?>">
<?php the_title();?>
</a></h1>
</div>
</div>
<?php endforeach; wp_reset_postdata(); ?>
<?php endif; ?>
</div>
So, the franchisee wants to change the picture for that block (which is a background css attribute, and they also want to change the link - which I believe could be changed by just changing the category of the page/post to home_04, right?)
Even though one problem was partially resolved, is there still a way I can add an editor to each microsite?
I need the option to build a page showing all posts of a specific category.
Showing all posts of a category can be done out-of-the-box by wordpress, I know. But I need the possibility to put some information about all those posts.
I know there's a plugin called "List category posts" (http://wordpress.org/plugins/list-category-posts/). It works but it's only showing the links to the posts. I need the full posts (like they are shown on the "blog page").
If you need to "do something" to results, look at
query_posts
via http://codex.wordpress.org/Function_Reference/query_posts
Here is a sketch that I think leans towards your needs using a custom loop. This can be inserted as needed via simple logic in your template:
// this sets up the filter parameters for a category id some_cat_id sorting asc
$args = array(
'cat' => $some_cat_id,
'order' => 'ASC'
);
// The query is applied via a conditional
if($some_conditional) { // for what ever reason we use the filter+args
query_posts( $args );
// this is also an opportunity to "do stuff" before the loop/output
}
// The Loop (simple example)
while ( have_posts() ) :
the_post();
echo '<li>';
the_title();
echo '</li>';
endwhile;
// Reset Query
wp_reset_query();
As a long time WP user I avoid plugins at all costs in preference of writing sustainable code. Plugins are a point of failure and some of the biggest plugin factories out there are nothing but security issues wrapped in sugar.
Custom loops via conditionals using query "filtering" is amazing and this pattern can be extended to category, search, tags, and meta key:value pairs.
Additionally, by understanding the loop the formatting and output can be controlled in a manner that is easy to sustain. Some of the plugin logic is horrid and very inefficient, so always investigate any and all plugins when performance and security are important.
Here's what I find to be the most simple way to do this:
<?php query_posts('cat=25&showposts=3'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
//You can change up the format below any way you'd like.
<li class="homeblock" style="max-width:400px;">
<div class="entry-thumbnail">
<?php the_post_thumbnail(); ?>
</div>
<div class="contentbox"><?php the_excerpt(); ?> </div>
</li>
<?php endwhile; endif; ?>
You can add this to a theme template file and all you need to change is the category id to the category you are trying get posts from. For example if your category id is '114' and you would like to show 9 posts it would look like the following:
<?php query_posts('cat=114&showposts=9'); ?>
If you need to add more info to the posts you should consider using custom fields to do that. Check out the plugin called Advanced Custom Fields.
Here is an example of a custom field being used in a loop:
<?php query_posts('cat=25&showposts=3'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<li class="homeblock" style="max-width:400px;">
<div class="entry-thumbnail">
<?php the_post_thumbnail(); ?>
</div>
<div class="contentbox"><?php the_excerpt(); ?> </div>
<?php $article_link=get_post_meta($post->ID, 'article-link', true);?>
<?php if ( $article_link ) : ?>
<?php else : ?>
<?php endif; ?>
</li>
<?php endwhile; endif; ?>
In the above example, if the custom field 'article-link' has a value, then that value (a URL) is used as the href in a link instead of the permalink of the article.
Hope I have helped!
i would like to have a sidebar appear in a single posts for a specific category. I not great at php so this is what i have been able to come up with. It does not work of course lol. Your help will be very much appreciated!
<?php if( in_category('9') ) : ?>
<div>
<h1>Other Products I Recommend</h1>
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('products2')) : ?>
[ do default stuff if no widgets ]
<?php endif; ?>
</div>
<?php endif; ?>`
There are two options for that:
There is a plugin that can help you with this. It's called jetpack. When it is installed and activated, when you add any widget to a sidebar there will be a visibility option, click that and choose which pages/categories/etc to show the widget it.
Code:
As for your code:
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('products2')) : ?>
that says if the dynamic_sidebar function doesn't exists or if it's not the products2 sidebar then do X. That function will exist as sidebars are set in that function, so nothing inside that if statement will run.
You will want something like:
<?php if( in_category('9') ) : ?>
<div>
<h1>Other Products I Recommend</h1>
<?php dynamic_sidebar('products2'); ?>
</div>
<?php endif; ?>
that should display the contents of what you have added to the products2 sidebar only when you are in a post that has a category id of 9.
Does anyone know what the best way to implement a list/grid togglable view in wordpress would be?
To be more clear: the default view shows the posts in a list, I would like to have the option to show them in a grid.
I have so far created a loop which shows only the thumbnails, and included it in another template.
But I don't know how I would link to that view. Would I best off using an archive view?
Thanks.
One of the easiest solutions is to create a page template containing a grid view and add a link to this page in the list view. Very simple but just what you need.
I had the same issue with pagination. WordPress has built in function posts_nav_link that automatically prints links to previous and next pages if needed. The problem is that this function works only with $wp_query instance of WP_Query (this instance is used by default, for example to get page's content or the latest posts in home). So the solution for you:
<?php
$temp=$wp_query;
$wp_query=null;
$wp_query = new WP_Query('showposts=4');
while(have_posts() ) : the_post(); ?>
<?php the_post_thumbnail( array(160,160) );?>
<h2><?php the_title(); ?></h2>
<?php endwhile;
posts_nav_link();
$wp_query = $temp; ?>
I think that's quite obvious and there is no need of explanation :) should be working
Thanks dude. I kind of got it working for now with this:
<?php $latest = new WP_Query('showposts=4'); ?>
<?php while( $latest->have_posts() ) : $latest->the_post(); ?>
<?php the_post_thumbnail( array(160,160) );?>
<h2><?php the_title(); ?></h2>
<?php endwhile; ?>
I think my mistake was trying to get it to use get_template_part( 'loop', 'grid' ); It would show the page, but no posts. Even if used get_template_part( 'loop', 'index' );
I'll need to figure out the pagination, but I'm putting it down for now to work on something else.
Thanks for your help so far! #Gediminas
I just installed Views module for Drupal 7 and am trying to find out how to customize it.
So far, I have done the following things.
Created a content type specified views and named it as 'videotest'.
Created a custom theme as 'views-view-list--videotest.tpl.php'
The page is working without a problem.
Here is the custom template code I used (this is the default template from Views):
<?php print $wrapper_prefix; ?>
<?php if (!empty($title)) : ?>
<h3><?php print $title; ?></h3>
<?php endif; ?>
<?php print $list_type_prefix; ?>
<?php foreach ($rows as $id => $row): ?>
<li class="<?php print $classes_array[$id]; ?>"><?php print $row; ?></li>
<?php endforeach; ?>
<?php print $list_type_suffix; ?>
<?php print $wrapper_suffix; ?>
How do I prevent Views to format $row for me? I like to format each values in a node myself using foreach.
I tried to set the view style as 'unformatted' with unformatted custom template, but it also style each value for me.
You should to use fields templates not 'Display', 'Style', or 'Row'.
Or you can use both fields in 'Row' template. Ex:
print $fields['you_field_value']->raw;
Name of 'you_field_value' show as part of link in fields list of view display.
Or to get the value of field:
print $fields['field_pretitle_front']->content;
print $fields['your_field_value']->raw;
did not work for me, however the following did in my case.
$row->field_YOUR_FIELD[0]['rendered']['#markup'];