Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

Whats are the selectors called and how to find them? page.title etc

first-time

Solved by Karmalakas View solution

Started by Graham 2 years ago · 15 replies · 313 views
2 years ago

What is the name of selectors such as page.url, page.header.title, etc and how do I find a list of valid ones? (like a reference page - its hard to find when I dont know what they are called).

I am trying to get the page description in the search results for simplesearch. The default is "page.content |raw" but this renders the contents of the page in the results but I only want a one line description.

Im trying to migrate my site to Grav so Im new to twigs, markdown etc...
Thanks in advance!

Graham.

2 years ago

Define description in your case. If it's a separate field for the page and it actually has such name, then it would be page.description

2 years ago

I had tried this previously, and page.meta.decription. The results pages both have descriptions but it is not being displayed. page.url works, just not the description.

2 years ago

You need to check that page blueprint to see how it's actually called in code

2 years ago

from the blueprints? The meta data is imported from metadata.html.twig? Ive searched the blueprints and no description...

2 years ago

I think we're going in circles here and too much information is missing...

@Grayches:
I am trying to get the page description in the search results for simplesearch. The default is “page.content |raw” but this renders the contents of the page in the results but I only want a one line description.

What do you mean by one line description? How do you set it?

2 years ago

Im after trying to get the content of <meta name="description" content="foo"> to show as the result. I see now that its set globally for the whole site, which I will have to sort. But is there a way just to get the value of content output i.e. "foo" in this instance

2 years ago

It was cutting out my code snippets, sorry, new to this...

TXT
<meta name="description" content="foo.">

I want "foo" returned on the page.

I'll keep searching...

2 years ago Solution

This should be in the page.metadata.description, unless it's implemented somehow differently on your page

last edited 05/22/24 by Karmalakas
2 years ago

@Grayches, Have you had a chance to read the docs?

And also maybe /forum/general/the-art-of-asking-great-questions-t8554? Your answer is short of information as @Karmalakas has pointed out...

While reading the docs, pay special attention to:

2 years ago

I have read the docs and Im referencing them all the time. Still takes time to get your head around things and this answer is not there regardless.
My initial question was just for the name of the variable type from which I could of found the answer.
As explained in previous post my code was omitted but as you can see from my later post this is not a custom tag. Its a standard html meta tag.

2 years ago

@Grayches:
name of the variable type

They are just configuration options or configuration variables. I very much doubt you will find anything useful if searching for that.


@Grayches:
Its a standard html meta tag

Then, as I already said, page.metadata.description

2 years ago

This worked along with |join(' ') tagged on the end. Its seeing it an array for some reason. Thanks for your help.

2 years ago

Sounds like something is wrong in your configs 🤔

2 years ago

Yeah, I'll have to look into that... 😔

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 74 7 hours ago
General · by pamtbaau, 12 hours ago
1 47 12 hours ago
General · by Andy Miller, 1 day ago
0 44 1 day ago
General · by Marcel, 12 months ago
6 346 5 days ago
General · by Duc , 5 days ago
3 39 5 days ago