Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think that you are mixing the ideas, the <code>#</code> part of the URL is the client duty to focus in the specific element id. Nevertheless, I suppose that you want to do that to dynamically embed chunks of a particular part of the page trough javascript, I can think on two possibilities:</p> <p>One, compose the full page template with the different ids from different sub-templates, this is easy if you are using a template module, like <a href="http://www.makotemplates.org/" rel="nofollow">mako</a>, and make a cherrypy handler to return the indivudual parts, this is of course supposing that you are in control of the content of the page and the ids are not dynamic (generated from a db or something) and the main site is a bunch of <code>includes</code>.</p> <pre><code>@cherrypy.expose def page_part(section): tpl_name = 'page_%s.html' % section # validate that the template exists, then: tmpl = lookup.get_template(tpl_name) return tmpl.render() </code></pre> <p>Mako templates:</p> <p>page.html:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;div id="main"&gt; This is the main content of the site! &lt;/div&gt; &lt;h4&gt;Sections&lt;/h4&gt; &lt;div id="section_1"&gt; &lt;%include file="page_section1.html" /&gt; &lt;/div&gt; &lt;div id="section_2"&gt; &lt;%include file="page_section2.html" /&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>page_section1.html:</p> <pre><code>&lt;p&gt; Content of section 1&lt;/p&gt; </code></pre> <p>page_section2.html:</p> <pre><code>&lt;p&gt; Content of section 2&lt;/p&gt; </code></pre> <p>Or two, use jQuery selectors or something similar to request the page once and make the sub-selects in the returned html.</p> <pre><code>$.get('/page.html', function(data){ $('#this_page_id').html($('#sect_in_other_page', $(data)).html()); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload