Closed christophknoth closed 9 years ago
Hello,
Are you sure about that? I just checked this and I am not getting the same result. Changing upper case to lower case in the .yml
file's title: name
key: value pair changed the titles to all lower case for me.
Thank you @pbatts. I just figured page.page_name
gives the title from the folder in title case page.title
gives the title from the yml file. Would have been handy if I could only use the folder names. Would have saved some work.
Hey @christophknoth @pbatts you can use Twig filters for this to achieve what you want. For example the filter "lower" will force lowercase, try this:
{{ page.page_name|lower }}
or captialize
{{ page.page_name|capitalize }}
or title (title case)
{{ page.page_name|title }}
Filters found here: http://twig.sensiolabs.org/documentation
@o-l-e thanks for the input, as always. Filters a great also. I was imagining @christophknoth needing a combination of lower and upper case in the title. But, now, you have me curious. Could the filter be applied only to the first character? If so, that would essentially disable the page_name
function in the core code.
@christophknoth In case you wanted to take a peek, the page_name
core function is located at stacey > app > page-data.inc.php beginning at line 102
@pbatts i could not find a filter that does exactly what you want (filter only the first character), but it can be achieved in a hacky kind of way.
{{page.page_name[:1]}}
outputs only the first letter
{{page.page_name[1:]}}
outputs everything but the first letter
if you combine the first line with the upper-filter, and second line with the lower-filter, you get what you are looking for:
{{page.page_name[:1]|upper}}{{page.page_name[1:]|lower}}
outputs first letter uppercase + the rest in lowercase
As i said it is not perfect, but does what you are after. Found a comment at the end of this thread that gave this solution: http://stackoverflow.com/questions/8998914/twig-how-to-get-the-first-character-in-a-string
oh and @christophknoth are you simply looking for the folder name? If so this is simple:
{{page.slug}}
outputs "page-name"
I was looking for something that also would give me Upper and lowercase and no hyphens. But I guess that was a stupid idea anyways because there are problems with diacritics depending on the server configuration.
All words in the titles always start with an uppercase letter. I guess this makes sense in English but maybe not in all other languages (e.g. in German). Maybe this should be rather done in the templating language and not set as a default?
Does anybody know if there is an option to disable this?