How do I include all documents in the Sphinx globaltoc sidebar? - python-sphinx

I would like every single document in the entire TOC to be included in the globaltoc sidebar. How do I achieve this?
In theme files, there are calls to {{ toctree() }}, but I don't know what toctree() refers to.

You can use the sphinxcontrib-fulltoc sphinx extension to include a complete TOC in the side bar.

Related

How to remove "Next/Previous topic" in the Sphinx sidebar?

While using the basic theme, I have noticed that Sphinx (v3.2.1) seems to be generating "Next/Previous topic" sections. Is there any simple way to remove those?
Add the html_sidebars option to your conf.py file and pick the elements that you want in the sidebar. This overrides the theme's default sidebar elements. You can also add custom HTML elements to the _templates directory and include them in the sidebar, as well as customize what the sidebar displays on different pages. See the Sphinx docs for more info on the sidebar elements Sphinx provides by default.
Obviously this differs between themes since not all of them include rellinks in the sidebar, but for the out-of-the-box theme this should remove the previous/next topic links and display on the TOC and search box.
html_sidebars = {
'**': ['globaltoc.html', 'searchbox.html']
}

Kentico8 - Show / hide a webpart or transformation depending on path

On our website, we have a logo on top. What I want is the following:
If the website's path starts with: 'www.website.com/books' The Logo should be 'books.png'.
If the website's path starts with anything else, it should be 'logo.png'
The logo is loaded in a repeater webpart. I can set the visibility of the books.png webpart to:
{%NodeAliasPath.StartsWith("/books/")#%}
Which works, The logo shows up if I go to, say, website.com/books and website.com/books/harry-potter, but I want the normal logo on any other website.
First I tried to make some sort of If statement in the transformation of the repeater itself. This way I will only need one webpart, that changes content depending on the path. But it looks like Kentico won't allow If statements inside a transformation. I still prefer an option like this, since it feels cleaner to me.
The other option is I make two repeaters, one with the normal logo.png, and one with books.png. But how would I hide the logo.png if the path starts with /books?
Or if anyone has another solution to this problem, let me know :)
Thanks.
Easiest option is to just have 2 repeaters or webparts for this so it's easily visible in the Design tab.
Your visibility macro for the /books should be:
{% CurrentDocument.NodeAliasPath.ToLower().Contains("/books") %}
And for the other webpart you'd enter:
{% !CurrentDocument.NodeAliasPath.ToLower().Contains("/books") %}

Generate Markdown Posts in Jekyll and Made Available to Paginator Variable

Is it possible to generate a set of posts in _posts as Markdown files in a way that they are treated as if they had been manually created and therefore, available to the process of creating the site pagination? I found examples of how to generate pages in various places like this SO question, but they seem to put the rendered content in _site and displaying the {{ paginator.total_pages }} variable does not yield any value.
Yes its possible to add "dynamic" content using a generator plugin.
You can generate pages, posts, collection's items, static files, anything you want.
For the {{ paginator.total_pages }} returning nothing. The paginator variable will only be available in your pagination template and nowhere else.

Jekyll/Octopress: How can I use a tag inside a tag

In Jekyll/Octopress, how can I place the output of a tag inside another tag?
This is what I want to do (using Octopress's img tag):
{% img {% PluginThatOutputsAURL %} %}
If I do that I get this error:
Error processing input, expected syntax: {% img [class name(s)] [http[s]:/]/path/to/image [width [height]] [title text | “title text” [“alt text”]] %} %}
Is it possible to do this? What would be the right syntax to do so?
Jekyll/Octopress uses Liquid Templates to parse these things.
As far as I know, you can't call two functions within a tag like that. You can however specify variable names in tags:
using Liquid variables inside of a liquid tag call
I tried Googling a bit and didn't see anything pop up for calling two functions within one tag.
IMO, I'd recommend creating a custom tag to do exactly what you want. I have created several custom plugins to Octopress because I needed such customization. The plugins, which is just Ruby. is pretty straight forward.
So, copy the existing img_tag.rb and call it, mycustom_img_tag.rb or whatever, and perform your magic within the render() method.
For example, here's my HTML5 audio player tag I wrote where I needed to know what extension the audio file was (specified in the url) in order to specify the content type:
https://github.com/eduncan911/eduncan911.github.io/blob/b89f47cd86c37f2cfb5c3093612fe0a049808325/plugins/audio_tag.rb
^- NOTE: It is incomplete and all the options doesn't work as I specified. You can see what works in the render() section, where I just parse the data-* attributes manually (I ran outta time and just made it work).
I basically used two other plugins as a template and created this one.
You have access to the entire Octopress methods and variables in your plugin - there are no restrictions to the entire code base.

PyroCMS: How to include one page inside another

I have a site with an "About us" page which is divided into multiple sections.
About Us
+Overview
+The Company
+Our services
+Future plans
(etc)
I want to have a floated block on the right hand side of each of these pages which contains links to every other page.
Ideally, what I would like is to create a page titled AboutUsSidebar, and then be able to include this page in all of the about sections through some kind of tag, ie..
{include('Sidebar')}
Is there anything like this in PyroCMS? Or perhaps a better way to do it?
You should use view partials.
Create your sidebar with it's HTML and save it into addons/shared_addons/themes/yourtheme/views/partials/sidebar.html and then you can include it in your layouts as so:
{{ theme:partial name="sidebar" }}
It looks like page types are the way to go, I didn't see the page types button at the top of the page before.
In the end what I was able to achieve the desired result by using a page type.
I have a page type called "About" which contains the sidebar html, then I use pages on top of that page type for each of the sections.
Worked very nicely.

Resources