I am building a simple menu. Among layouts I've considered is a plain-jane dropdown that looks like this for numerous items:
<li>
Fare
<ul class="nav-dropdown">
<li>Tomatoes</li>
<li>Cheese</li>
<li>Bacon</li>
</ul>
</li>
This seems very functional, but there are often the #! characters appended to the URLs when I navigate among pages. Of course if I eliminate those characters, the dropdown behavior stops altogether.
Are there other means for coding anchors to eliminate these from URLs?
Related
We're having a weird problem in our AEM 6.3 application.
For some reason, the link to the contact-us page gets rendered with a space at its end, making it useless.
I'm trying to figure this out but I'm kinda new to sightly (I used to be working on CQ5).
To visualize it better, the configured link in the page properties is:
/content/app-name/hk/hk/info/contact-us
And the code in the HTML/sightly page is:
<a href="${inheritedPageProperties.linkToContactUsPage # extension='html'} ">
Contact Us
</a>
While what gets rendered in the actual page is:
<a href="/hk/hk/info/contact-us%20.html">
Contact Us
</a>
This happens only in the chinese pages of the site, I'm not sure if this is relevant or just a coincidence.
At first I thought the problem could be the blank space at the end of the href attribute, but shouldn't it result in "/hk/hk/info/contact-us.html%20" then? Also why would this problem affect only the chinese language pages and not all the other languages?
AFAICT you do have a space in the page properties link:
Please remove the space in your
<a href="${inheritedPageProperties.linkToContactUsPage # extension='html'} ">
like this
<a href="${inheritedPageProperties.linkToContactUsPage # extension='html'}">
I am using the ThemeMachine and also trying the CustomThemeMachne themes - they reveal I should have an aside1, 2, and 3 .. I was under the impression that Aside was Aside of the main content and not underneath the main content; and that is where they show up now - right under the main content. What I would like to have is my Aside1 to the Left Side of the Entire Page for various content such as article links and Adverts and also an Aside on the Right side of the Entire Page. See the picture below where RED Rectangle is the page menu / main content / etc , the Blue rectangles are the Aside 1 and Aside 3
I am having some difficulty in figuring out how to do that - since I am really new to Orchard and my skill sets with MVC model are limited.
I would like some guidance or an example of exactly how I can accomplish this with either of these two themes after an example or really good info I feel I will be able to figure out what I need to do.
The rectangles are called zones. These are defined in the Theme.txt. Search for a line that starts with Zones:, it states each zone in a simple comma separated list, for example:
Zones: Navigation, Content, UserDisplayName, ...
The actual render order of the zones is defined by HTML markup in the Layout.cshtml, for example:
#{
Func<dynamic, dynamic> Zone = x => Display(x); // Zone as an alias for Display to help make it obvious when we're displaying zones
}
<div>
<div>
You are logged in as #Zone(New.UserDisplayName())
</div>
<nav>
#Zone(Model.Navigation)
</nav>
<div>
#Zone(Model.Content)
</div>
</div>
This is all well documented at http://docs.orchardproject.net/en/latest/Documentation/Anatomy-of-a-theme/
With knockout you can produce a row of bootstrap nav-tabs like this
<ul class="nav nav-tabs question-container" data-bind="foreach: Questions">
<li role="presentation" data-bind="css: { active: $index() === 0 }">
<a data-toggle="tab"
data-bind="attr: { href: '#q' + QuestionId() }">, text: Caption"></a>
</li>
</ul>
With bootstrap-sortable you can make the tabs sortable simply by changing the binding. A limitation clearly documented is that you can't use the sortable binding with virtual elements because it depends on being defined on a single container element.
Suppose I wanted to add a tab "Add a new question" presenting various options for what to create, after the manner of the add-new tabs used in Chrome, Internet Explorer, Firefox and Microsoft Excel.
If I weren't trying to make the tabs sortable, I'd do this:
<ul class="nav nav-tabs question-container">
<!-- ko foreach: Questions-->
<li role="presentation" data-bind="css: { active: $index() === 0 }">
<a data-toggle="tab"
data-bind="attr: { href: '#q' + QuestionId() }, text: Caption"></a>
</li>
<!-- /ko -->
<li role="presentation" data-bind="css: { active: Questions().length === 0 }">
<a data-toggle="tab" href="#addQuestion">
<i class="fa fa-plus"></i>Add a new question</a>
</li>
</ul>
By adding a marker class "sortable-item" to the <LI> in the template, we can trivially exclude the meta item by defining item: ".sortable-item" in the bootstrap-sortable options. But it still won't fly, because you can't use virtual elements with bootstrap-sortable.
Does anyone know how to add meta items to a collection managed by bootstrap-sortable?
There are four ways this problem can be approached.
Don't use bootstrap-sortable, apply jQuery-UI sortable explicitly and ise sort update events to update the backing store collection.
Use bootstrap and inject the meta items after binding completes.
Modify bootstrap to support the notion of a meta-items template in addition to the binding template.
Modify bootstrap to use the immediate parent of a virtual node. There is always a parent, even if it's BODY.
Personally I favour option four, because it doesn't change how bootstrap-sortable is applied, it simply removes a limitation. No breaking changes.
Option three is nearly as good but it increases the conceptual complexity and makes the learning curve steeper.
Option two sucks big rocks. It screws up separation of concerns.
Option one, which is what I actually did, sucks even bigger rocks. Not only does it pollute the view model with UI behaviour, it's complicated to do, depends on poorly documented and obscure knockout internal utilities and it's just plain ugly. Everything about it is a justification for the existence of bootstrap-sortable.
In answer to this comment:
The "add question" button is not a question, therefore it should not
be part of the list of questions
It's not a list of questions, it's the UI for a set of operations that can be performed on a list of questions. Most of them are "display item X for editing" but one of them is "create a new item". Also present are controls for deleting items and for re-ordering them.
I find it hilariously ironic that anyone would claim this is not an obvious UI design while using a web browser - a ubiquitous example of this exact design
It doesn't seem like there is currently a better story than the workaround I mention in the question. The ideal solution would be for me or someone else to write a knockout binding. Most of the code in bootstrap-sortable seems to have to do with templating the rather nifty table it generates, but I think the required lessons are there.
Is there an equivalent to Smarty's {strip} in erb?
To clarify:
I'm not looking for .strip. Read the docs on Smarty's {strip};
Whitespace between tags is significant and matters very much when you try to match widths and so on. For example, if you have this code:
<ul>
<li>Something</li>
<li>Something else</li>
</ul>
and the lis have display: inline, there will be a space between them even if they have no margin. That space appears because of the whitespace between </li> and <li>. So, the only solution to not have that space between the <li>s is to do this:
<ul><li>Something</li><li>Something else</li></ul>
Which is pretty fugly and you end up with huge, unreadable lines when you start putting <a>s in the <li>s and so on.
There is always the "traditional" method of putting spaces inside the tags (still valid XML):
<ul
><li>bla</li
><li>bla</li
></ul>
You have the following options
in Haml you can do with > and <
in ERB the ERB::Compiler::TrimScanner maybe could help you out, but I've never used it. As far as I understand, it would look like this: <%w capture do %>
here comes your code with whitespaces
<% end %>
What is the strategy in smarty for using different variables each time a template is included in another template?
Here is what I mean.
I have a smarty template that creates a simple navigation list.
<ul class='linkList'>
<li>
<h3>{$title}</h3>
<ul>
{foreach $links as $d}
<li><a title='{$d...}' href='{$d....}'>{$d.text}</a></li>
{/foreach}
</ul>
</li>
</ul>
I want to include it a number of times in my main template and each time pass it different values. Im not sure what strategy to use to do this.
If I assign variables in my php file like this
$smarty->assign('links',array(.....);
$smarty->assign('title','My first link list');
$smarty->assign('links',array(different values);
$smarty->assign('title','My second link list');
and then include the template twice i will just get the same list twice with the second lot of values.
The {include} tag allows you to pass variables in the call:
{include 'linklist.tpl' title="Sample Links 1" links=$link_array1}
{include 'linklist.tpl' title="Sample Links 2" links=$link_array2}
Otherwise, I'm pretty sure you can use either {assign} or the short form of assign ({$var=value}) before including the template.