By miles28 on
Hi
How could I add this symbol "|" between each item for primary links using a phptemplate theme?
First item | Second item
Thanks in advance.
Hi
How could I add this symbol "|" between each item for primary links using a phptemplate theme?
First item | Second item
Thanks in advance.
Comments
Maybe you should look at
Maybe you should look at this page http://drupal.org/node/44708
submitted by Dublin Drupaller a few minutes ago
try this..
In your page.tpl.php file..where the primary links are placed..use this code and edit it to insert you're own delimiter.
I used this before to convert it to an unordered list.
In non progammer speak, it splits the primary_links apart and then outputs each one seperately.
Hope that helps
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
You could also do this
This is a variation on Dublin's solution which saves you from keep track of first/last link (to avoid an extra delimiter)
It sets $link_delimiter is set to what you want to visually seperate the links by. $delimiter is set to the html plus link delimiter that seperates the links. In this case it is the closing list tag (to close the previous link), the link delimiter and an opening list tag (for the next link item.) Finally it prints the opening link tag (for the first link) followed by the links seperated by the delimiter and ending with a closing link tag (for the last link)
class in $link ?
how can I add a class identifier for the a tag?
like in this situation a.nav
Thanks
José Fernandes
Bloomidea
Use preg_replace()
I use this in a phpTemplate theme:
And more advanced (due to my incomplete understanding of how the $primary_links variable is served, I can't get a for() loop to work):
works in 4.7
yep, the code above works for me in 4.7.
I used
that way, you can add whatever html/css to your primary links ($link).
--
Don't hate the media, be the media -- www.indymedia.be
If I want to add a class to
If I want to add a class to each link that was based on the text of the link, I have to use some pretty complex regular expression manipulation. Wouldn't it just make sense for the theme to get each individual component of the link (text, path, attributes, ect) for more flexibility? It's frustrating that we have to use memory and time to break apart are string that was just generated earlier in menu_primary_links(). Or is there another way?
i think i want to do the same thing
diggersf, are you trying to get an "id" in the surround <li> tags to each link? i've been trying to find some documentation on this as well.
does anyone know how to get the information from the links you created?
incremental IDs and classes
I'm also looking to output an ID based on the text from the link.
I'm no PHP programmer but I've settled on the following to at least create a unique id for list items:
This way each link can be styled with CSS. For example the first link in the primary nav is output with an id of "primarynav1"
I'm also using a snippet to give each page a unique body id.
http://drupal.org/node/46024
By using the combined IDs for the section Nav can be highlighted. eg.
The drawback is that the stylesheet needs a declaration for each combination.
As I said I'm not a programmer so I'm hoping for a better solution if anybody can suggest one.
even better Unique Ids on menu items
Khalid B posted this on the themes list...
http://2bits.com/articles/adding-unique-styles-to-primary-and-secondary-...
It's a much better fix for creating unique Ids
Apparently this functionality will be included in 5.0
Unique Ids for primary links *as images*
These last two fixes both seem to work well. Can anyone help me figure out how to combine Khalid B's fix with the snippet at http://drupal.org/node/62149 which changes primay links to images? I know little-to-no php and just don't know how to make the mechanics work in 4.7. Thanks a million.
Does this work with 4.7
Thanks for the snippet
I tried this on 4.7 bluemarine and I can't seem to get it to work.
Do I need to call a function in a template.php file? As described at:
http://drupal.org/node/44708
Or is there simply something I am not understanding, maybe a change in how primary links are handled in 4.7?
Thanks for any ideas/advice
Primary links snippet posted by Dub
Dub,
Thank you for posting the primary links snippet in the Customising links node - I found it very helpful as someone who's just starting out with theming. I originally started out with xtemplate and had already sorted out horizontal navigation using a ul in the primary links. However, when I moved over to phpTemplate I was struggling to recreate the horiz. navigation until I came across your snippet - thank you once again.
Just what I was looking for, now what....
I was just looking for a way to convert the primary links to an unordered list for a new template that I'm converting to work with Drupal.
Now what I need to know is how to set the id of the active primary link to a specific style?
In the template that I'm converting, it uses the following code:
How do I style the primary link menu to fit this format?
As flexible as Drupal is for the non-programmer, templating is still in the dark ages of using PHP.
- Alan Tutt
http://www.PowerKeysPub.com
- Alan Tutt
Exceptional Personal Development for Exceptional People
http://www.PowerKeysPub.com
theme_item_list
See http://api.drupal.org/api/4.7/function/theme_item_list
That page is for programmers, not designers
Thanks for pointing out the program code that generates the primary links, but that's not at all what I'm looking for. For one, it's PHP, and for another, there is no mention on that page whatsoever about the "current" active link.
I'm not a programmer, nor do I want to learn PHP just to design the layout of my site.
- Alan Tutt
http://www.PowerKeysPub.com
- Alan Tutt
Exceptional Personal Development for Exceptional People
http://www.PowerKeysPub.com
That's strange. It happens
That's strange. It happens automatically in my phptemplate bluemarine version.
----
Acknowledging a reply to your question motivates the replier to answer more.
The other one didn't work : I use this one
Hi !
I use this one with Phphtemplate Drupal 4.6.6
Drupal 5.0
Has any one got this working with Head? I get the word array for each navigation item when I try implementing it.
You need to do
print theme('menu_links', $primary_links)thanks
thanks for that; it also helped me figure out why my primary links weren't showing up after moving a theme from 4.7.0 to 4.7.4 installation (didn't realize the menu code changed that much?). In case it helps other users, my original code was:
which worked fine in 4.7.0 but no longer displayed the Primary Links in my 4.7.4 environment. Changing to the following did work again:
Thanks gazelle et al
Does it work for Drupal 4.7.x?
I'm using this code to display "|" between my primary links but the delimiter is displayed only after the first primary link. eg: Link1 ||| Link2 Link3 Link4
this is my code:
I have worked on this all day..Can anyone help me? I really don't know what I'm doing wrong.
Here is the html displayed by the code. It shows that the delimiter is printed after each link, but in reality all 7 delimiters are printed after "Home"
I hope my problem is clear enough. If not, ask me for more detail.Thanks
for Drupal 4.7.x and 5.x
this is the code:
don't work for me
i tried adding what you posted above to my code and it does nothing, am i missing something? (using drupal 5)
alternatively i could just add a space and / when i create the menu using drupal gui but i would rather theme it
also I would like to do the same thing in my footer which i have made using a custom block-footer.tpl.php
Check the theme function
You use
<?php print theme('menu_links', $primary_links, '/'); ?>but the theme function 'menu_links' only expects one argument and does not expect/use the seperator argument. The theme function 'links' does not expect a seperator for the second argument. You can check out the core theme functions for Drupal 5 at http://api.drupal.org/api/group/themeable/5.You could override the theme function adding the needed argument or provide your own theme function.
Side note, your use of menu_primary_links looks odd as the second argument should be a parent menu id.
Displaying all but the first link
I'm using the Zen template.php and a custom front page. In my front page I want to print all the links except the first link (because that first link is "home" and you're already there!). How would I go about doing this?
The code I'm using to display the links is:
foreach ($primary_links as $link):endforeach;Meh
If I just used my brain for another 2 minutes...
I added a counter variable, and had it skip the loop on the first pass. Problem solved. This would work for any link in your array, just by changing the original number for the counter and changing when you increment the counter.
$counter = 0;foreach ($primary_links as $link):endforeach;Edit: Doing this shows /node/112 type links. If anyone knows how to access the array to pull the /custom-url portion, I'd be grateful.
primary links in 5.x
Hi,
I tried to use this wunderful code for primary links in my personal theme
The problem is that I use external links in my primary menu and with this code they don't work correctly. The base_url is added at the beginning of my external link, so I have this at the end in my menu:
http://www.mysite.com/http://www.externallink.com
Do you know how to fix it?
Thanks
This may help
You could try replacing
with
works good
Thanks a lot, your code works perfectly good. Waaaaw!!!!
Hi All
Hi All
i used the below code to display primary links with images in my(drupal5.x dev)site.
its working fine But am getting primary links text and image side by side like
'[image1][text1] [image2][text2] [image3][text3] [image4][text4]'
but i need primary link text under the image like
'[image1] [image2] [image3] [image4]
[text1] [text2] [text3] [text4]'
Can any give solution for this asap.
Thanks in advance.
--------------------------------------------------
function primary_links_add_icons() {
$links = menu_primary_links();
$level_tmp = explode('-', key($links));
$level = $level_tmp[0];
$output = "
\n";- '. preg_replace($l2i['pattern'],$l2i['replacement'],$link) .'
$l2i['pattern'] = '$()(.*)()$ie';
\\2\\3'";
$l2i['replacement'] = "\"\\1\".'
if ($links) {
foreach ($links as $link) {
$link = l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment']);
$output .= '
';
//$output .= preg_replace($l2i['pattern'],$l2i['replacement'],$link);
};
$output .= '
';
}
return $output;
}
Primary links images only 5.2
I am trying to change my primary links into clickable images only no text. Can anyone help. I really need this to be fixed.
Thanks for any help.
Hi go thru this
Hi go thru this link
http://drupal.org/node/62149
in that Check
"4. FOURTH SOLUTION: display icons (images) but no text"
will be your solution .
override+CSS solution to original problem, Drupal 5
I also needed pipe-separated menu items.
But I didn't want them in the text - instead, I wanted them as CSS borders + padding.
What I did:
1. override theme_links function, by commenting out this chunk:
and then adding just below it a single replacement line
and adding some code to add first/last classes to Anchors:
(I added this block just below the "Automatically add a class to each link and also to each LI" block).
2. use horizontal padding around Anchors, and use border-right to display pipe-like separator.
Also, use that 'first' class to display the pipe-like separator before the first link (using border-left).
Little explanation for the override part: When first/last classes are applied to list-item and not anchor, it's not really possible to portably CSS the left border of the first link, thus I needed to move those classes into anchors.
-----
http://bogdan.org.ua/
New Window - Primary Link
Hi,
Im a newbie,can anyone teach me how to open a primary link in a new window for Drupal 6?
The link goes to 3rd party application which located in internal server so I can't use extlink module.
Please Advise,
Thank you very much
Drupal 6 and l()
Not sure I can find a Drupal 6 version of this, but I've used the following code to theme my links as it provides full support for localisation and path aliasing, while still maintaining full themability. I've included the code on how to add you own classes to links so you can grab hold of them and theme them through the CSS.