I want to order my front page by last modification, following the steps in its documentation it says this code
{{ range .Data.Pages.ByLastmod }}
Should work, but I am getting the posts ordered by date, not lastmod.
Note: Actually I am using paginator, so the code I am using is
{{ range .Paginator.Pages.ByLastmod }}
I've also tried the first snipped, but still ordering by date.
Anyone knows why?
Thanks
First you must set the lastmod field in the front-matter. If you decide not set the field, then the lastmod date falls back to the date field in the front-matter.
If you wish to implement some automation, then you need to initialize your project as a Git repo, set flag enableGitInfo = true in the config file. You may find the details here: gitinfo
Commit your repo changes before every build and you will see the .Lastmod date change accordingly.
Related
I can't figure out how to set up the links. I have created a collection. I need an creator to be automatically specified in that record when adding a record to the collection. How do I do that?
I've faced this problem...
I found the solution in the documentation:
need to add
"populateCreatorFields": true
in the file (strapi v3) /api/your-type-name/models/your-type-name.settings.json
in options object
like:
...
"options": {
"increments": true,
"timestamps": true,
"draftAndPublish": true,
"populateCreatorFields": true
},
...
More information can be found at strapi documentation
Strapi does not support it by default. As mentioned in this form you can achieve it by editing the strapi's controller. But I will not recommend you to edit the strapi controller at all. Please avoid it.
There is a simple and better solution to this. You can achieve this by creating one to one relationship. Create an author table/collection. Make one to one relationship with your other collection. You can make it a required option as well. So whenever someone creates an entry they have to select an author from your already created collection of authors.
And now you can get relation in your API and use it wherever you want to.
As stated in my comment, Strapi (tested on v3) comes with a created by field. To ascertain the claim, the following steps can be followed;
Create a new content type. Here I am setting only one field, called test
Add an entry for that content type. Notice the last update and by field on the right.
Save and open the entry. The last update and by fields have been automatically populated.
I am using github api to get all the details from github. I want to get the commit date time of a particular tag of my repo.
For example: To get the tags of this repo used as example I do:
https://api.github.com/repos/fastly/epoch/tags
which returns me list of all the tags. Suppose I want to find the commit date time of tag named "0.3.4".
One way to do this is iterate over each tag in the array of tags and get the commit url of "0.3.4." i.e.
https://api.github.com/repos/fastly/epoch/commits/1560ef3cca58b71a9481ede2819d46d3a7a6ce51
which has the details of the commit date time.
But is there a way to directly get the details of the commit date time of the tag? I tried the following:
https://api.github.com/repos/fastly/epoch/tags?ref=0.3.4
https://api.github.com/repos/fastly/epoch/tags?path=0.3.4
https://api.github.com/repos/fastly/epoch/tags?name=0.3.4
All these links, returns me a list of all the tags same as what I get when I do - https://api.github.com/repos/fastly/epoch/tags?ref=0.3.4
Instead of displaying the list of tags and searching your tag within it, you rather could use the lower level Git Data - References api to directly access one particular tag, provided you know its exact name.
Syntax: GET /repos/:owner/:repo/git/refs/:ref
Example: https://api.github.com/repos/fastly/epoch/git/refs/tags/0.3.4
This will return the following Json payload
{
ref: "refs/tags/0.3.4",
url: "https://api.github.com/repos/fastly/epoch/git/refs/tags/0.3.4",
object: {
sha: "1560ef3cca58b71a9481ede2819d46d3a7a6ce51",
type: "commit",
url: "https://api.github.com/repos/fastly/epoch/git/commits/1560ef3cca58b71a9481ede2819d46d3a7a6ce51"
}
}
>I was wondering if there is a way to do get the required details in just 1 step.
As of now, there's no way to directly jump from a tag name to the peeled target. FWIW, besides a commit, although not that common, a tag could point to
a tag anotation (which may also link to another one):
e.g. https://api.github.com/repos/libgit2/TestGitRepository/git/refs/tags/annotated_tag
a git object different than a commit (e.g. a blob)
e.g. https://api.github.com/repos/libgit2/TestGitRepository/git/refs/tags/blob
Do you know of any way to check the current time in Joomla considering the selected time zone in global configuration?
I have been looking in administrator settings but did not see any single word about the current time.
You can use the following code:
$date = new DateTime();
$config = JFactory::getConfig();
$date->setTimezone(new DateTimeZone($config->get('offset')));
This does two things. The first line creates a DateTimeobject based on the current server time and timezone. The following two lines get Joomla's global configuration and change the timezone of out date object to that timezone.
You can then format the date to whatever format you like by calling $date->format('Y-m-d H:i:s');. You can replace the format specifier by whatever you need, a reference of possible formatting options can be found here: http://www.php.net/manual/de/function.date.php
I have to following drop down list
{{ Form::select('selected_site', $select_sites, Input::get('selected_site')) }}
it works fine and I see the name is "selected_site" but how do I set the HTMl Id of the element? I find nothing on this in documentation.
Thanks!
There's one more argument:
{{
Form::select(
'selected_site',
$select_sites,
Input::get('selected_site'),
array('id' => 'yourid')
)
}}
In this last one you can add anything else you need, 'class', 'data-whatever', etc.
There are 2 ways to do this.
You can setup a Label using the Laravel Form builder and use the same name on the control associated with it. As per the documentation at http://laravel.com/docs/html#labels (take a look at the note under this section) After creating a label, any form element you create with a name matching the label name will automatically receive an ID matching the label name as well.
As answered by #antonio-carlos-ribeiro, the 3rd parameter of the control takes a list of options on which you can setup the additional attributes for the control.
Hope this helps...
I'm working on importing (on a regular basis) about 6,000 items into Magento using Magmi. I've got nearly everything configured the way I need it, but I have one issue.
I need to concatenate 3 columns from my .csv file to create a "category_ids" column. I'm using the Value Replacer plugin with the following value:
{item.departmentid},{item.classid},{item.subclassid}
This works well, however I need to then map this field to another field using the Generic Mapper plugin. Both functions work individually, however I need the Value Replacer to run BEFORE the Generic Mapper. As best as I can tell, it appears the Generic Mapper runs first. Is there a way I can alter the execute order for these two plugins?
Thanks for the help!
Update for Dweeves:
Doh! I totally overlooked that section while trying to figure this out. Now that I've gone through it, I might need a little more help. Right now I've using just the Value Replacer plugin with the following settings:
Replaced attributes: category_ids
New value for category_ids:
{{ ValueRemapper::use_csv('/var/www/magmi/category_ids.csv')->map({item.departmentid},{item.classid},{item.subclassid}) }}
It doesn't seem to be working as I intended it to, but I'm a systems guy and not a PHP programmer. Any help?
2nd Edit
I got it working by using the Value Replacer function to first concatenate everything into a new "test" column, then using the Value Replacer Value Mapper function to create the category_ids column with the mapped values. Confusing, but it's working well.
You can use the ValueRemapper helper of Value Replacer plugin for this kind of purpose.
See Value Replacer Plugin Documentation (ValueRemapper helper section)
To answer your original question (how to define the order the plugins run in).
From my experience, the plugins are loaded in order of their plugin filename.
For example, if you look at magmi/plugins/base/itemprocessors/importlimiter, you will notice that the filename for the plugin is 01_importlimiter.php.
If you look in the genericmapper plugin folder, you'll notice the plugin filename to be 02_genericmapper.php.
With this being said, 01_importlimiter.php will execute before 02_genericmapper.php.