Displaying entries per category in ExpressionEngine - categories

So, I've searched, and found a few posts that kinda get me what I want, but it still doesn't quite work. This post especially seemed closest to what I was trying to achieve, and I built my code off of it: http://expressionengine.com/forums/viewthread/168142/
To explain; I have a series of entries, each entry is assigned to only one category. I'd like to list out these categories and, beneath each category, list out the entries with one of their custom fields. Like so:
Category 1
Item 1
Item 2
Category 2
Item 1
Item 2
So, here's my code as it stands now, which lists out the categories, but doesn't spit out any of the entries at all:
{exp:channel:categories channel="faq-question" style="linear"}
<section class="faq-category-container closed">
<h1 class="faq-category-header">{category_name}</h1>
<dl>
{exp:query sql="
SELECT title, url_title AS urlt, cat_id
FROM exp_channel_titles
NATURAL JOIN exp_category_posts
WHERE channel_id = '7' AND cat_id = '{category_id}'
ORDER BY title ASC"
}
{embed="jazz-camp/faq-cat-list" faqlink="{urlt}"}
{/exp:query}
</dl>
</section><!-- end .faq-category -->
{/exp:channel:categories}
And the embedded template it references:
{exp:channel:entries channel="faq-question" url_title="{embed:faqlink}"}<!-- entry -->
<dt>{title}</dt>
<dd>
{faq_content}
</dd>
{/exp:channel:entries}
Any help would be most appreciated!

This may be a very basic example of what you're after:
{exp:channel:categories style="linear"}
<h1>{category_name}:</h1>
{exp:channel:entries category="{category_id}" dynamic="no"}
<p>{my_custom_field}</p>
{/exp:channel:entries}
{/exp:channel:categories}

So, here's what I ended up with at the end (courtesy of some help over at the EE boards):
{exp:channel:categories channel="faq-camp" style="linear" show_empty="no"}
<section class="faq-category-container closed">
<h1 class="faq-category-header">{category_name}</h1>
<div class="faq-questions-container">
<dl>
{embed="jazz-camp/faq-cat-list" faqlink="{category_id}" faqparent="faq-camp"}
</dl>
</div><!-- end .faq-questions-container -->
</section><!-- end .faq-category -->
{/exp:channel:categories}
And as for the embed, it looks like this:
{exp:channel:entries channel="{embed:faqparent}" category="{embed:faqlink}" dynamic="no"}<!-- entries -->
<dt>{title}</dt>
<dd>
{faq_answer}
</dd>
{/exp:channel:entries}
The reason for the embed has to do with how things are pulled in with regards to getting the correct channel entries; simply having the {exp:channel:entries} inline in the page didn't quite work.

The Category Archive tag might be helpful to you:
http://ellislab.com/expressionengine/user-guide/modules/channel/category_archive.html

Related

jquery .html() returning null in ie7

On click li element i am getting the current element value and appending it into another div dynamically.Its working fine in all browsers.But returning null in IE7.I don`t the reason that why its happening?Please can any one give me a solution for this..Part of the code only i pasted here.
Sample code:
////////////.//This line returning null in IE7./////////////////
$('#pagelink_a #pagelinkli_'+tab_lastid_val).html()
(tab_lastid_val value can be a 1 or 2 or 3.Clixked li element value comes here)
<div class="pagelink">
<div id="pagelink_a">
<ul>
/******** all li element are clickable***********/
<li id="pagelinkli_1"><a>Google</a></li>
<li id="pagelinkli_2"><a>Chrome</a></li>
<li id="pagelinkli_3"><a>Firefox</a></li>
</ul>
</div>
</div?
try this:
$('#pagelink_a').find('li[id=pagelinkli_'+tab_lastid_val']').html();
code is not tested but i think it should work.
Given your html layout, your parent div is .pagelink not #pagelink_a , so replace your following line:
$('#pagelink_a #pagelinkli_'+tab_lastid_val).html()
for this one:
$('.pagelink #pagelinkli_'+tab_lastid_val).html()
Just use
$('#pagelinkli_'+tab_lastid_val).html()
The # tag identifies an ID which only a single element may have. There is no need to have anything preceding it. You also labeled the previous class as id, which is wrong. I don't know how your other browsers managed to get anything.
Although bit off topic, it may be better to actually drop IE7 support entirely. Due to small user base and decreasing popularity, it may be costing you more money by support it than to not support it.
Try instead of html() , and try append().
For example
$('#ID').append('Your content');

How to get first and last items number with Zend Paginator?

I need to get the fisrt item and last item number in my view.phtml.
The trouble is that I can't acces this properties in my pagination control, because of the structure of the html. For example:
<div class="list">
.... rows ...
<div class="items"> 1 - 18 of 540</div>
</div>
<div id="pagination">
<?php echo $this->paginator; ?>
</div>
Is there anyway to access to those properties from the view? I just can't figure out how can I do it.
First item will be 1 and last item count would be $paginator->getTotalItemCount();
There is example code in the Zend documentation, where first and last page links are generated.
$this->paginator->first;
$this->paginator->last;

How should I handle schema.org markup for a product with multiple sizes/prices

While implementing schema.org markup for one of my cusomters online-shops I noticed a little difficulty. I think it's a missing option in the markup. Neighter offer nor aggregateOffer can handle this case correctly - although I think it is quite common.
One page for one product (let's say it's a body-lotion)
The body-lotion comes in 3 sizes, 100, 200 and 250ml
It basically has an internal productId (BL100, BL200 and BL250) for each size as well as a EAN (http://en.wikipedia.org/wiki/International_Article_Number_(EAN)) for each size.
How to buy: Go on the product page, chose your size, the price changes via javascript, click add to chart
Q: How can I markup ONE product with MULTIPLE sizes and MULTIPLE prices correctly?
Problems:
http://schema.org/Product suggests only ONE productID which is wrong for me. If I add three offers (http://schema.org/Offer), search engines might think, the pricing is totally weird because the same product has three different offers.
http://schema.org/AggregateOffer doesn't seem right to me eighter.
Thanks for your help.
I think the correct way to mark up this particular scenario is by nesting several Offers inside of a single Product. To add additional information to each Offer, use an IndividualProduct. I'm not 100% sure, but this seems to work well in the Google Structured Data Testing Tool.
It looks like schema.org is still being updated with new ways to markup your products. The schema.org project pulled in a lot of structure from the Good Relations e-commerce product vocabulary. See E-commerce SEO Using Schema.org Just Got A Lot More Granular for more information about the new vocabulary items.
Say we want to list information about Sumatra coffee beans for sale on a website. We want to sell two different sizes (12 oz. and 16 oz.) with different prices for each. However, both product sizes should have the same images ('tis just a coffee bean) and name. The structure will look something like:
Product (name, description, and image)
aggregateRating
Offer (price and priceCurrency)
IndividualProduct (sku and weight)
Offer (price and priceCurrency)
IndividualProduct (sku and weight)
Copy and paste the following into Google's Structured Data Testing Tool to see how Google will interpret the HTML.
jsFiddle display
<article class="product" itemscope itemtype="http://schema.org/Product">
<div class="images">
<a href="images/product.jpg">
<img alt="Sumatra Coffee Beans" itemprop="image" src="images/product.jpg">
</a>
</div>
<div class="content">
<header>
<h1 itemprop="name">Sumatra Coffee Beans</h1>
</header>
<div class="code">
<span class="label">Item Number:</span>
<span itemprop="productID">sumatra-coffee</span>
</div>
<div itemprop="description">
<p>Error 418</p>
</div>
<div class="reviews" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<div class="details">
Rated <span itemprop="ratingValue">4.5</span>/5
</div>
<div class="count">
(<span itemprop="reviewCount">9</span> reviews)
</div>
</div>
<div class="offer" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<div itemprop="itemOffered" itemscope itemtype="http://schema.org/IndividualProduct">
<span class="sku" itemprop="sku">scb-ov1</span>
– (<span itemprop="weight">12 oz.</span>)
</div>
<div class="price">$<span itemprop="price">14.99<span></div>
<meta content="USD" itemprop="priceCurrency">
</div>
<div class="offer" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<div itemprop="itemOffered" itemscope itemtype="http://schema.org/IndividualProduct">
<span class="sku" itemprop="sku">scb-ov2</span>
– (<span itemprop="weight">16 oz.</span>)
</div>
<div class="price">$<span itemprop="price">20.99</span></div>
<meta content="USD" itemprop="priceCurrency">
</div>
</div>
</article>
I think I would have one Product that contains multiple Offers, one per size. The limitation, of course, is that it doesn't offer a formal means for specifying multiple product IDs, but perhaps you could informally put those in the Offer's Description or URL property. That's not an exact fit, but maybe it's close enough.
Another option is to join the Public Vocabs email list (lists.w3.org/Archives/Public/public-vocabs), which asserts that it is "the place to propose extensions, new types, or feedback from deployment experience with the existing vocabulary" (lists.w3.org/Archives/Public/public-vocabs/2011Oct/0162.html), and propose a solution to your problem.
I think ProductGroup is the key. See https://schema.org/ProductGroup
I have a similar quest and I find it hard to match google suggestions for xml product feeds with schema.org specs. Thing is, that feed should include each sku as single feed item (each shoe size separately), yet wa sell them as one product with different sizes. Our developer uses AggregateOffer to link all the sizes together, but specs does not allow each offer item to differ or even include an sku field. Product seems to suit the case better. Both sku and +size* are valid, properties of Product. Different sizes should be linked by productGroup.
In your case I would look into ProductModel for grouping multiple Product options, as it allows PropertyValue fields. See https://schema.org/ProductModel
I would recommend a slightly different way of thinking about this particular web page. Instead of thinking about this specific webpage as a 'Product' page, think about it as a 'WebPage' type. This 'WebPage' then actually contains three different 'Products', each with their own 'Offer' and their own 'productID'. When you're saying that each size has it's own EAN, that's a big indicator to me that each size's price/size/id should be contained inside if it's own 'Product' div.
This is what Google says to do: Use itemOffered The item being sold. Typically, this includes a nested Product, but it can also contain other item types or free text.
All the different variations should be represented as separate Products with separate Offers. Use Product's isSimilarTo and isRelatedTo properties to link them together.
reference: http://schema.org/Product
Consider using "AggregateOffer" for the product, than within each offer specify each size as a different "itemOffered"
https://schema.org/itemOffered
While several common expected types are listed explicitly in this definition, others can be used. Using a second type, such as Product or a subtype of Product, can clarify the nature of the offer.

Email travel package info from user (CMS Made Simple, CGECommerce, Cart, Products, etc.)

I am using CMS Made Simple along with all of Calguy's plugins for e-commerce(Products, Orders, Cart, etc.)I can't quite figure out how to make what I need. How can I make a form with items from the Products module and checkboxes for each, and at the end a total and lost for the checked items is sent to the owner of the site? Any pointers would be appreciated much, I can figure out the rest.
If you use the Cart Module you could try customizing a viewcart template under "Viewcart Form Templates".
Once products are selected you can use another template to put the contents of the cart in an email. Something like this can be used to create a really basic list + total listing:
{if !isset($cartitems) || count($cartitems) == 0 }
<p>No products in the cart.</p>
{else}
<ul>
{foreach from=$cartitems item='oneitem'}
<li>
{$oneitem->quantity}x {$oneitem->summary} ({$currencysymbol}{$oneitem->item_total|number_format:2})
{if $oneitem->quantity > 1}
({$currencysymbol}{$oneitem->base_price|number_format:2} each)
{/if}
</li>
{/foreach}
</ul>
{$total_text}: {$currencysymbol}{$carttotal|number_format:2}
{/if}
You can always temporarily insert {$cartitems|print_r} into your template to view the attributes that are available for use in the smarty code.

Selecting child div by id knowing a parent div id with JQuery selectors

I have this html:
<div id="top">
<div id="potato"></div>
</div>
<div id="bottom">
<div id="potato"></div>
</div>
I am trying to use JQuery to access the bottom potato div, and none of the following work.
$('#top #potato').html('Russet');
$('#bottom #potato').html('Red');
$('#top > #potato').html('Russet');
$('#bottom > #potato').html('Red');
$('#potato').html('Idaho');
All of these just modify the top div and not the bottom one. How do I modify the bottom div?
All elements must have unique IDs, in this case you may use the class attribute, so that you have
<div class="potato" />
Which you may access like this:
$('#bottom > .potato').html('Idaho');
I just ran into this problem. Although it's true you shouldn't have two items with the same ID, it happens.
To get the div you want, this is what works for me:
$('#bottom').find('#potato');
For one thing you can not have an element that has the same id as another. Id is unique, but class names can be used as many times as you want
<div id="top">
<div id="potato1"></div>
</div>
<div id="bottom">
<div id="potato2"></div>
</div>
jquery as so:
$(function{
$("#potato2").html('Idaho'); //if you're going to name it with an id,
// that's all the selector you need
});
What you posted and said doesn't work seems to work to me.
$('#top #potato').addClass('Russet');
$('#bottom #potato').addClass('Red');
https://jsfiddle.net/wzezr706/
no need to put classes on everything, but you should have unique id's for everything. That aside, try this:
$("#bottom + div").html('Idaho');
Try this:
$("#bottom #potato").html('Idaho');
Or
$("#bottom #potato:last").html('Idaho');
your HTML is not valid, since you have non-unique ids