Extra Block Types (EBT) - New Layout Builder experience❗

Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.

Demo EBT modules Download EBT modules

❗Extra Paragraph Types (EPT) - New Paragraphs experience

Extra Paragraph Types (EPT) - analogical paragraph based set of modules.

Demo EPT modules Download EPT modules

Scroll

Children of children not appearing in book navigation menu

Children of children not appearing in book navigation menu
, by

I have a "Our Staff" Content Type, that includes a field for uploading an individual's CV as a PDF:

field_cv_file

I have created a View for this Content Type, then added it to page via Blocks

The twig file I'm using to render/style this area is:

views-view-fields--our-staff-view--block-1.html

I'm having trouble with the URL for the File Field

I can render it as a PDF icon link like this:

{{ fields.field_cv_file.content }}

But I want to obtain the 'raw' URL to apply inside a href, something like this:

<a href="{{ fields.field_cv_file.content }}">Download CV</a>

This however is not working.

I've tried a few different ways of rewriting the code in href, but none are working.

how would I do this?

1 answer
votes: 390
Answer

book_children(), which is used in the preprocessor for the "book_nagivation" theme hook (template_preprocess_book_navigation()) only retrieves the immediate children of the current book item, so you wouldn't expect the default "Book navigation" block provided by the Book module to show all children of the current book item recursively.

If you wanted to modify the behavior of this block in your theme, you could clone the template_preprocess_book_navigation() from book.module, placing the function in the template.php file for your theme and renaming it to yourthemename_preprocess_book_navigation(), and then create and call a modified clone of book_children() that recursively collected all links in the book beneath the passed link.

If the behavior you wanted was to display the standard tree for all interior book pages, but display book's entire outline only when you are viewing main page of the book, you could alter your yourthemename_preprocess_book_navigation() function so that it only calls the "get recursive tree" function when the $book_link doesn't have a parent ($book_link['plid'] == 0), and call book_children() for all other cases.