How to sort pages in reverse chronological order? - sorting

I want to display pages in reverse chronological order based on page's name. Is there an easier way to do this than changing the page names?
Here is the Kirby's example.
/content/blog/20121212-my-first-article
/content/blog/20132206-a-second-article
/content/blog/20142806-the-latest-article
I want the latest post – 20142806-the-latest-article – to be displayed first.

There is a kirby method named flip: <?php $articles = $page->children()->flip() ?>
https://getkirby.com/docs/cheatsheet/pages/flip

Related

Adding Joomla Article Order number inside an article

I am trying to create a Joomla site that would be showing the article order numbers (not Article ID) inside each article. that way I can handle it like a book.
Each page will show the article order number at the corner - like a page.
That way I will be able to have the site modeled by categories and pages will show with their page number (Article Order number) at the corner.
I want to give the user the ability to watch the pages like they are reading books by categories.
I would be happy to know - how can I add the article order number (for each category) inside the article itself.
I am sure that there is a PHP code that can do that.
Thanks so much for your help and assist.
Arye
You'll need to override the default article layout in your template.
If your template doesn't already have an article layout, you can copy the default layout from components/com_content/views/article/tmpl/default.php inside your template override templates\[YOURTEMPLATE]\html\com_content\article\default.php (replacing [YOURTEMPLATE] by your actual template name.
You can then display ordering where you require it within your template by using
<?php echo $this->item->ordering; ?>
You'll most likely want to either check for a certain condition (the article's category, perhaps) to determine whether you want to display the ordering.
Another option is to create an alternative layout instead of overriding the default one. You can rename default.php in your template to, let's say bookpage.php. You will then be able to pick the new layout as an alternative layout in your articles' options.
you can get article id by using
Request::getVar('id');
for more you can check the link
Joomla plugin : how to get article title and article id
for jquery you can do like this. you can create a function and call on every page load it will sort all your content accordingly. you can assign other attributes also in foreach loop.
<div id="allArticles">
<article id="3">Article 3</article>
<article id="1">Article 1</article>
<article id="2">Article 2</article>
</div>
$("#allArticles article").sort(function (a, b) {
return parseInt(a.id) > parseInt(b.id);
}).each(function(){
var elem = $(this);
elem.remove();
$(elem).appendTo("#allArticles");
});
more you can see the working example here http://jsfiddle.net/THMu3/

Magento content management; prevent a mess

So, I started on a new project this week and of course I'm thinking about the problems I'm going to find during the whole development process. We are going to make a shop that has a pretty good design, pretty excited to work on this. However, the design uses a lot of content that can't be placed in the normal functions of magento. For example there is a catalog page that has a lot of content blocks with secondary information like unique selling points or a bit of story telling. This can and will be different for different categories. We are talking about a lot of small content blocks, not something you can cram into the category description field ;)
Until now I mostly used static blocks to make this content and show them on the pages, maybe even use xpath to extract the information I need from the blocks to prevent the end-user from destroying the design by using the WYSIWYG editor. However, I don't think this will be a good solution now because there will simply be to much static blocks to create and use without loosing the overview of everything, plus I doubt xpath is really good performance wise (something like getting a screw in with a hammer).
I was thinking about making a module or using a module that makes it possible to add attributes and use attribute sets in combination with static blocks. With that you can make your own fields and groups for certain pages and make it easy for the end-user to edit information on their webshop. However, making this myself (does sound like a lot of fun) will take to much time, and I can't really find a module that does something like this.
How do you guys solve these problems when creating a new webshop? Any tips?
I suppose you will be using your own theme with own template for the category page, here you will setup all the HTML that you don't want the admin to mess up with the WYSIWYG editor and let them change only certain parts of the page. For the admin to be able to edit these, you will need to add new attributes to the category entity. For example if the admin should add text for a certain box, add text type of attribute, if the admin wants to add HTML create WYSIWYG editor type of attribute and so on. Then in your template you will check if the category has any of these attributes and they have non-empty values then print them.
For example:
<?php if ($category->getCustomTextAttribute() != ''): ?>
<div id="your-div">
<?php echo $category->getCustomTextAttribute(); ?>
</div>
<?php endif; ?>
<?php if ($category->getPromotionHtml() != ''): ?>
<div id="promotion-div">
<?php echo $category->getPromotionHtml(); ?>
</div>
<?php endif; ?>
This goes the same for the product pages with the difference that for products you can create the attributes via the admin and then print them on the product page template, otherwise for Categories you need to write a module that does this, if you want me I can provide you with an example of module for creating Category attributes.
I ended up using a combination of zokibtmkd answer and adding fields to the default static blocks (a image upload function and a link field). The combination of these two solutions gave me enough to work with in the design without messing up the admin or the templates.

Getting article create date joomla

I'm trying to get article's created timestamp or date so I can format it with css. I've searched on google and on the forum but, I'm confused on the result.
I've done this:
echo $this->article->created;
echo $this->item->created;
And is giving me a blank result.
What am I doing wrong?
Looking at the page layout
https://github.com/joomla/joomla-cms/blob/2.5.x/components/com_content/views/article/tmpl/default.php#L114
Line 114 you see how the date is rendered in 2.5.
<dd class="create">
<?php echo JText::sprintf('COM_CONTENT_CREATED_DATE_ON', JHtml::_('date', $this->item->created, JText::_('DATE_FORMAT_LC2'))); ?>
</dd>
So to style it you can just use the create class or you can make a layout override.
This is assuming you want it in an article. If you want it in a list or something look at the appropriate layout for that. And if you want to override the date format itself do that in a layout override.
The element you want seems to vary by version, so make sure whatever you are cribbing off of, matches your installation.
First of All where you are trying to display the created date.
1) In normal article views like default joomla catgory ,blog or any other view.
You should check the following.
The article options that available on the right side options of articles the created date is show true.
Then Also make sure If it assigned to a menu there also these options available there also
make true.
Then you will get the created date in the articles default view.
2)If you are trying with a custom code section you can find some codes like this.
$useDefList = (($params->get('show_author')) OR ($params->get('show_category')) OR ($params->get('show_parent_category'))
OR ($params->get('show_create_date')) OR ($params->get('show_modify_date')) OR ($params->get('show_publish_date'))
OR ($params->get('show_hits')));
on the article default view of joomla.In any version of joomla these should be based on article options values.
Hope this may help you...

assign image to category and it's posts on WordPress

I want to assign an image to a category and it's posts on WordPress. When adding the new post it will take the image and assign to it's container category. If you have any way to help or plug-in to do that, I would be really grateful.
Based on your question, I think you are trying to show posts (or maybe post excerpts) from multiple categories in a single list and include images in these posts based on their individual categories.
If there is only one place you are trying to display these images and if they will not change very often, you could include some conditionals directly in The Loop.
<!-- Test to see if the post is in a given cat and apply a custom class for styling -->
<?php if ( in_category('CATNUMBER') ) { ?>
<div class="SOME-CUSTOM-STYLE">
<?php } else { ?>
<div class="GENERIC-NON-STYLED-POST">
<?php } ?>
Once you have custom classes on the divs by category number, you can style a background image in your CSS. Alternately, you could spit out an tag right in the loop.
If you foresee adding new categories and/or changing pictures often, you will probably want a cleaner way of doing this. If you only have a handful of categories or if you are comfortable making changes to the loop often, this would work fine.

Magento - Where do I go to edit file that outputs the sitemap?

I would like to update the template that generates the google sitemap in Magento 1.5.
Reason being, Magento is using the URLKey (e.g. /my-jacket.html) and not the full URL with category (e.g. /outerwear/jackets/my-jacket.html).
I'm doing this in another place on the site (an .html sitemap) and it works great. When looping through products inside a category...
// get the categories for this product
$_categories = Mage::getModel('catalog/product')->load($product_id)->getCategoryIds();
$_category = Mage::getModel('catalog/category')->load($_categories[0]);
// build the URL path
$url = Mage::getUrl($_category->getUrlPath()).basename($_product->getUrlKey());
// only problem is this will be /category/category2.html/my-jacket.html
// so strip the .html and put it on the end
$url = str_replace(".html","" ,$url) . '.html';
It's ugly but works. Anyway, I want to do the same to the google sitemap that gets generated, but after much searching for where it is generated, I can't find it. Anyone point me in the right direction?
I'm fairly certain that there's no simple template to edit. The XML generating happens inside of a model, specifically: Mage_Sitemap_Model_Sitemap::generateXml().

Resources