I am using ExpressionEngine 2.2.1 and am trying to create a conditional that will cause a page to show a specific navigation template based on the page's category. For example, I am creating a public profile for someone who is a part of a competition in London. When someone visits his profile, I would like the page to show, not only his profile, but also a banner with an image of London & navigation that is specific to the London competition. I would like to do this by adding a conditional with categories since we have so many competitors in many different cities. I have created a category titled "London Competitors English" and it has the ID of "56". Once I have created the competitor's profile within EE, I select the category, "London Competitors English," however, when I go to the page, the default navigation template is loading rather than the London template. I created code based on my research and most related example here: http://expressionengine.com/forums/viewthread/185555/. What do I have wrong in my code?:
FILE ONE: (condensed portion of) competitor_profiles_en/index.html where "competitor_profiles_en" is the template:
{exp:channel:entries limit="1" url_title={segment_2} }
{embed="includes/header"}
<div class="xx">
<h2>{competitor_first_name}<br>{competitor_last_name}</h2>
...
</div>
{/exp:channel:entries}
FILE TWO: (condensed portion of) my header.html file :
{if segment_1 == 'home'}
{embed="includes/_nav_landing"}
{if:elseif "{categories}{category_id}{/categories}" == "56"}
{embed="includes/_nav_city_lon_en"}
{if:else}
{embed="includes/_nav_internal"}
{/if}
The problem is that embeds are processed after all other tags, in a completely separate process. So when your includes/header embed runs, it has no categories to speak of, because it's not actually running within a Channel Entries tag.
Unless you need to pass variables to includes/header (which you don't appear to be doing here, but you may have removed that for simplicity), I'd move your includes/header to a snippet instead, so it will be processed inline with your Channel Entries tag.
Derek's answer was spot on, and I would like to elaborate on my method of putting his suggestion into action.
I found information about snippets here http://expressionengine.com/user_guide/templates/globals/snippets.html and watched this tutorial here http://www.youtube.com/watch?v=AEEudo0BrRA&feature=related. I then created a snippet within the control panel (Design > Templates > Snippets) that included all of the code that was in the header file and titled it snippet_header_en. Because ExpressionEngine includes snippets as a part of the template that they are in, EE recognized my conditional including the categories that I created. Here is the revised code:
FILE ONE: (condensed portion of) competitor_profiles_en/index.html where "competitor_profiles_en" is the template:
{exp:channel:entries limit="1" url_title={segment_2} }
{snippet_header_en}
<div class="xx">
<h2>{competitor_first_name}<br>{competitor_last_name}</h2>
...
</div>
{/exp:channel:entries}
FILE TWO: (condensed portion of) my header.html file :
As previously mentioned, I moved this code to the snippet section of the EE control panel.
Related
Let me assume that I have the following architecture
_components (folders)
x1.html
x2.html
x3.html
I have a first page where I got the information from the YAM section for every component.
At this point I would like to add a link for every component to another page where I will display the component in a bigger manner.
So, let me assume I have, in the first page :
<div class="col-md-1">
<span id= "logos" class="material-icons"></span>
</div>
and In the componentbig.html I would like to open the right component on the basis of the link.
Do you have any suggestions for me ?
If I understand You correctly, then collections might be the feature You are looking for. For example, I'm usually using collections to generate a list of products and then have a specific page for each product also. Also make sure You check the easy tutorial by Ben Balter.
Hi sorry if this a daft question (newbie), I am currently using mediawiki-1.23.1 and have been looking for a way in which to create it easy for an end user to create a page. However I would love to be able to have a link auto-created/auto populate on the current page. I currently use the InputBox extension. But it doesn't seem to allow this additional function from my research. Is this a possibility through extensions, or will this have to be done via a custom php template?
current InputBox details.
<inputbox>
type=create
width=24
break=no
buttonlabel=Create new page
</inputbox>
Any help or direction would be really appreciated.
It is impossible to create a link from page A to page B automatically if you don't "mark" something on page B. And the simplest thing you can mark is "[[Category:...]]", like Bergi said. I will use preloaded text to make it easier.
What you need
If you want page in main namespace to be the page where end users type in InputBox, you need any extension that will show content of category page such as Extension:CategoryTree, or Extension:Dynamic Page List (see also Transclude a category in MediaWiki).
Steps
On page [[Template:PreloadedText]]
Put the following content
<!-- Do not edit under this line -->
<includeonly>[[Category:CreatedFromPageA]]</includeonly>
On page [[A]]
Put the following content
<!-- Show all pages in [[Category:CreatedFromPageA]] -->
<!-- Assuming you use Extension:CategoryTree -->
<categorytree hideroot="true" namespaces="-">CreatedFromPageA</categorytree>
<!-- InputBox -->
<inputbox>
type=create
width=24
break=no
buttonlabel=Create new page
preload=Template:PreloadedText
</inputbox>
For end users
On page [[A]], they will see every page that was created via the InputBox at the top. At the bottom, they will see the InputBox. After typing pagename and clicking the button, they will be brought to the page they typed. There will be the following text existing already
<!-- Do not edit under this line -->
[[Category:CreatedFromPageA]]
As long as they don't bother with these lines, after they click save, the new page will appear on the list automatically.
I'd like to make the database of famous musicians using dokuwiki.
Musician has their own Biography, Discography, Members, and Live Concert Info.
For example, Aero Smith. They have many CD released. and historical events.
So does Live Concert Info.
That's why basically I'd like to make all the page separated something like this.
Aero Smith (Main Page of Aero Smith)
Biography
Discograhy
Members
Live Concert Info
I was talking about only Aero Smith. But there will be other famous musicians, too just like this.
Red Hot Chilli Peppers (Main Page of Red Hot Chilli Peppers)
Biography
Discograhy
Members
Live Concert Info
So each band should have 5 pages for total including Main Page.
Then here's my question.
Is it possible to let these 5 pages have the same menu which has links to other pages?
For example, I want the Table of Contents(or Side Menu) which has link to these
Main Page(of Aero Smith)
Biography(of Aero Smith)
Discograhy(of Aero Smith)
Members(of Aero Smith)
Live Concert Info(of Aero Smith)
Of course, this will be shown only in Aero Smith's content page.
In other musician's page, their menu will be shown up just like "Main Page(of Red Hot Chilli Peppers)"
and one more thing. I want this "Table of Contents(or Side Menu)" just as menu for links to the other pages.
I don't need the same name header in a page. All I want it is only for the links to the other pages.
I just want it as menu that indicates links.
Are they possible with dokuwiki? or Is there any other wiki that can make all of these possible?
HUSTEN, you can certainly do this following the guidelines for creating Namespace Templates and placing 'relative' links in the template in order to link to the sub-pages. (See the 'aside' below in regard to namespace/page naming.)
Place the following markup into your page named: bands:aerosmith:main
Menu: [[.:main | Main Page]] [[.:discography | Discography]] [[.:members | Members]] [[.:live | Live Concerts]]
Note the use of .: in the links to create 'relative' links to the current namespace. See DokuWiki Namespaces
You may also want to add any common headings or sections into this page as well as the menu links (as this will be your template).
Now follow the instructions on the Namespace Templates page to copy /bands/aerosmith/main.txt to /bands/__template.txt (note the double underscores which will make the template apply to all sub-namespaces within the 'bands' namespace).
Now, whenever you create another band page, such as bands:red-hot-chilli-peppers:main, it will automatically be populated with this menu of links to the other pages (and you have the benefit of just clicking the link in order to create the page).
A brief 'aside' in regards to DokuWiki pages and namespaces:
If you create a new 'page' named bands:aerosmith
then you end up with a Namespace named 'bands' which contains a Page named 'aerosmith.txt'
But if you create a new 'page' named (note the trailing colon) bands:aerosmith:
then you end up with a Namespace named 'bands' containing another Namespace named 'aerosmith' which contains a Page named 'start.txt' (if you haven't changed the default page name in the configmanager).
So, if you use my instructions above, you will end up with a Namespace named 'bands' and a Namespace named 'aerosmith' and a Page named 'main.txt'. BUT you do not have a page named 'start.txt' so if you attempt to browse to /bands/aerosmith then you won't see the 'main' page as it will (by default) attempt to show you the 'start' page in that namespace.
I'm writing an application, a reporter with heirarchy of folders and files, in the lower heirarchy level there are 2 types of reports: the simple one is a flat (non link) report that being presented as a single simple line.
the second type is a link with a general description in the header and if you press the link you get a full report.
example: if I run a telnet command, I will see the command in the header and if I want to see the entire session with the device I will press the link and it will be presented.
My problem is that most of this lined-files are small but the OS reserve a minimum space for every file so I loss alot of disk space for nothing.
The solution I want to implement is a "dummy" links, which will be presented and will behave like a regular links but actually will be stored in the same file like their "parent" (probably with alot of other links like them).
The solutions I saw so far are only for "jumping" inside a page but this is not what I'm looking for, I want it to be presented like a seperated file and I dont want the "parent" file to present this information at all (the only way to see it will be by pressing the link and even then it will present only this information and not the other file content).
any idea guys?
To link to a specific part in a web page, place an anchor link where you want the user to go to when they click a link with:
<a name="anchor"></a>
and link to it with:
Click here
You can replace "anchor" with a more descriptive name if needed.
To hide/show a div (the following code is untested, but should work)
JQuery solution (If you're using JQuery):
function toggle(divname) {
$(divname).toggle();
}
The corresponding HTML:
<div id="content">some content</div>
<a onclick="toggle('content')">Click here to show/hide the content div!</a>
Non-JQuery Solution:
function toggle(divname) {
var adiv = document.getElementById(divname);
if (adiv.style.display === 'block' || adiv.style.display === '') {
adiv.style.display = 'none';
} else {
adiv.style.display = 'block'
}
}
The HTML:
<div style="display:hidden" id="content">Content</div>
<a onclick="toggle('content')">Click here to show/hide the content div!</a>
Is it possible to force the sitemap control to render the menu when the current action is not listed in the MVC.sitemap file?
I have a simple top nav. When the current action is in the sitemap, the call to .Menu() will render the correct <ul><li>.. data. However, if I got to a page that is not in the sitemap such as /Home/Login, then it will not render any html at all (not even a comment, just empty space). This isn't an [authorize] issue; the menu is fine when i'm in '/Home/Index'.
It seems like it should render what was requested, but just not set the IsCurrentNode and IsNodeInPath properties. Here is the call I am making
<div id="main-nav">
#Html.MvcSiteMap().Menu(0, true, true, 1)
</div>
The Mvc.sitemap file:
<mvcSiteMapNode title="Home" controller="Home" action="Index">
<mvcSiteMapNode title="Form New Human" controller="Person" action="Create"/>
<!-- there is no mvcSiteMapNode for "Home" "Login" -->
</mvcSiteMapNode>
Found the way around it. It apparently isn't a built in extension method, or at least I couldn't find one. You could call Html.MvcSitemap().Menu(Html.MvcSiteMap.Provider.RootNode,...) but I didn't want to instantiate the helper twice.
<div id="main-nav">
#{
var sm = Html.MvcSiteMap();
#sm.Menu(sm.Provider.RootNode, true, true, 2); // 2 levels (home, plus main nav)
}
</div>
Looking around in the disassembly seems to show that it works a little like this:
You really need a starting node
If you don't give it one, it tries to find one based on the current node
plus restrictions (forward searching, depth restrictions, etc)
if you want nodes from level 1, you have to know what level you are on
Since that returns null, starting node is null, which means the helper writes an empty string
There may be a combination of tricks, or an overload or two, which can be finagled into doing this, but I can't find it right now. This works for my needs (simple top menu). There has to be a simpler way to do this, something with wild cards, or route based, with a closest match thing going on. I figured menus were a fairly standard part of a web app, and this would be covered :)