I have a concrete5 site already using an autonav block in the global header for the main site navigation.
I now need to add a secondary navigation to the header containing different, less important links.
These links aren't necessarily to be shown in sitemap order, but I would prefer to use an auto-nav block if possible to do so.
Can anyone give me any tips on how to achieve this?
Can I get there somehow using Aliases on the sitemap?
Are you looking at using Bread Crumbs? We also use Mega Menu.. There are quite a few menuing systems from concrete5.org. Note: Mega Menu is not free, but is worth it.. The other thing is that sometimes the "File Tree" and "File Sets" may have to be re-ordered.. While in the file Tree, choose the option to update cache..
You should use a page attribute. You could use a checkbox for instance, call it secondary and if checked make your secondary nav to show it.
You can use a page list and an boolean attribute(for example: display_in_second_nav)
Here is an example:
$pl = new PageList();
$pl->filterByAttribute('display_in_second_nav');
$pages = $pl->get();
Also, you can sort results:
$pl->sortByRelevance()
Orders by index score descending. Only available when searching by keywords.
$pl->sortByDisplayOrder()
Orders by sitemap display order ascending.
$pl->sortByDisplayOrderDescending()
Orders by sitemap display order descending.
$pl->sortByPublicDate()
Orders by public date ascending.
$pl->sortByPublicDateDescending()
Orders by public date descending.
$pl->sortByName()
Orders by page name ascending.
$pl->sortByNameDescending()
Orders by name descending.
Related
How do allow users to change the order of posts, based on custom fields?
For example :
First custom field: Value1, second custom field: Value2.
In archive page, the posts are presented in order of the value 1 by default, and a filter (links) allows to order them according to the value 1 or 2.
Use the pre_get_posts hook as per the example here https://developer.wordpress.org/reference/hooks/pre_get_posts/#comment-2571. This assumes that your custom fields are stored as post_meta.
Note that you need to be very careful that you are only affecting the query that you want to affect at the time that you want to affect it. In this example they are checking that they are not in admin, that they only doing events (in your case you want posts) and that it is the main query (not another query that say a widget or some other function is running). Consider limiting it to the page that you want this to run on or putting the code in the theme template, so that it only runs for that template and not at any other time.
I have a shopping website and I allow users to list products. When they add a new listing, they must enter values from select box into main_category,sub_category and leaf_category fields in products_tbl.These fields are indexed because they make queries fast when viewing products. There is also is_reviewed flag in products_tbl which is 0 by default.
In my admin dashboard I get all listings that are not reviewed and check if they are in the right category. Almost all the time customers make mistake when they list so I edit the listing and update the indexed main_category,sub_category and leaf_category fields and change is_reviewed flag to 1. This means I have to update every time users list in wrong category and Its really becoming slow.
so what is the best way to do this? I have thought about creating another table and new listings stay there. so after reviewing I add them to to the products_tbl with correct categories. But I am not sure if this a good solution. I appreciate your help in advance
I use the Tx_news Extension (not TT_news) and have 2 pages where i show my newsitems. On Home I show only some topnews with the Listview, and there is a second page with the full News overview, the last one is ordered by Date & Time field.
But for the items on the Home I want a Manual sorting if it's possible.
I have added the following code in my resources:
$GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['orderByNews'] .= ",sorting";
This gives in the plugin the option for Manual Sorting, so that part works. Only How and Where can I order the News Items?
Note: I see in the Newsrecord table (tx_news_domain_model_news) the column sorting, my records are all 0 in there, I think its something with this, but can't get my finger on it.
I hope somebody can help me.
You need to set the news-plugin settings in ts-setup.
plugin.tx_news {
settings {
orderBy = sorting
orderDirection = desc
orderByAllowed = sorting,author,uid,title,teaser,author,tstamp,crdate,datetime,categories.title
}
}
I'm currently working on a site that will display a list of online shops,
Each shop will be stored on my database and I'll be using PHP to select and display them.
But since those shops will pay me, I want to let each shop to be on the top of the list sometimes,
(for example if the shop name starts with a "Z", they will probably complain for being on the bottom of the list all the time, so I want to keep it fair).
So I thought about letting each letter be on the top of the list for an hour, but i have no idea how to do that..
Is that even possible?
Thanks in advance!
I'd show a separate box and call it "today's pick" or something with just one shop in it. That way you can push the shops starting with "Z" to the top once in a while and at the same time keep the user experience of a list of shops which is sorted normally.
Then use the database to save which shop has been in the "today's pick"-box how many times to get them all up there equally.
There's no sane way (that I'm aware of) to handle this directly in SQL without adding a "priority" field to your schema (although it's possible, it would be convoluted at best). That said, here are two suggestions:
Modify your schema
Simply add a "priority" field to the relevant schema and sort by priority, name (or whatever the default is). You will of course need to reset the priority field every hour, but this is a fairly trivial task.
Handle it in PHP
Carry out the query as per usual.
Grab all the results into an array.
Re-prioritise as required based on the current hour. (You'll need to array_splice the item(s) you want to bump out of the array and then array_unshift them to the top.)
Output based on the array.
This will of course become more convoluted/less efficient if you need to handle pagination, but the basic idea is the same.
A nice solution would be to add another column to the database with the shop names, and call it something like "last_shown" then when you show this shop, update the column with a timestamp, and each select do something like:
"SELECT name,link FROM shops ORDER BY last_shown DESC"
then in php you could check
<?php
if($row['last_shown']+3600 > now()){
//run select but in ASC order
//update the new row's column to the current timestamp
}
?>
that way it will only update once an hour, but otherwise it will keep selecting the shop at the top of the list for the hour
sorry it's a bit of a mess i just typed this out quickly at work
You can add
1) a extra column as shown_times in schema
2) order by shown_times asc
3) & as a shop is shown you would +1
or
Another solution :
You can even use ORDER BY RAND()
I have to create a browse page like monter.com or dmoz directory. My problem is the counts for each category.
What's the best practive to do a similar thing?
I am using PHP/MySQL
Thx!
Did you try to implement it the way that you calculate these numbers dynamically when the page loads? How do you know that it is indeed a performance issue? Calculations are pretty fast these days.
Otherwise put a counter field next to each (sub-)category. When inserting(/deleting) a new post, then you update the counter of all categories it belongs to.
As a result, when you query any category, or set of categories, you will have a counter field for each giving the exact numbers of posts the category holds.
Solr can do that with Faceted Search http://lucene.apache.org/solr/tutorial.html#Faceted+Search
I'll test it now.