Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Keep the root element, remove following elements until the breadcrumb fits. I'd actually recommend you to do this in JavaScript as then you'd have methods to calculate the pixel width of the breadcrumb, whereas in PHP you'd have to use a fixed number of characters as the break point which would always result in different lengths. Using JS would be better anyways for SEO and such, as the links would still be there, only hidden.</p> <p>Assuming you have a simple list element as your breadcrumb:</p> <pre><code>&lt;ul id="breadcrumb"&gt; &lt;li&gt;&lt;a href="/"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/products/"&gt;Products&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/products/hats/"&gt;Hats&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/products/hats/large/"&gt;Large&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/products/hats/large/red/"&gt;Red&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/products/hats/large/red/round/"&gt;Round&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>You can then trim the length like this (using jQuery):</p> <pre><code>if($('#breadcrumb').width() &gt; 900) { $('#breadcrumb li:first').after('&lt;li&gt;...&lt;/li&gt;'); while($('#breadcrumb').width() &gt; 900) { $('#breadcrumb li').eq(2).remove(); } } </code></pre> <p>A simple example and probably doesn't work, but should give you some idea.</p> <p>BTW, if you want to do the trimming in PHP, you have to do it when the breadcrumb is being formed if you want to keep it simple. If you start trimming afterwards, you'd have to resort to some pretty complex regular expressions or to including some kind of DOM parser in your project to keep the anchor tags intact.</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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