Forums

TTFTitles help (7 posts)

  1. cmsme
    Member
    Posted 1 year ago #

    hi, i am building a site with the amazing TTFTitles plugin, and i am wondering if there is any way to use it to create images for the page titles in my navigation bar.
    although the plugin is great, the support documentation is a bit brief.

    many thanks

  2. lclarkberg
    Member
    Posted 6 months ago #

    I asked my friend Herb how to make ttftitles also work with WordPress menus (using wp_list_pages). He came up with the following code which you can use in place of wp_list_pages in your template.

    <?php
    			$pages = wp_list_pages('sort_column=menu_order&amp;title_li=&amp;depth=1&amp;echo=0');
    			if ($pages) {
    			preg_match_all('/<a.*>(.*)<\/a>/', $pages, $array);
    			$asize = count($array[0]);
    			for($i = 0; $i < $asize; $i++) {
    			$link = $array[0][$i];
    			$title = $array[1][$i];
    
    			ob_start();
    			the_ttftext($array[1][$i], $echo = true, $style="menu primary nav", $overrides="");
    			$ttf = ob_get_clean();
    
    			$originalLink = $link;
    			$link = str_replace(">" . $title, ">" . $ttf, $link);
    			$pages = str_replace($originalLink, $link, $pages);
    			}
    			echo $pages;
    			}
    		?>
  3. alectro
    Member
    Posted 4 months ago #

    Thanks a lot lclarkberg! this works just fine!

  4. lotech
    Member
    Posted 4 months ago #

    I'm looking into implementing this right now but can't seem to get it to stick. It seems to output the normal menu - although the code below is working - just no replacing the titles with the dynamic ttftitle images.
    I'm using an ol instead of the usual ul format list but it should be the same? The ttftitles style is called menu fyi.

    <ol id="dropmenu">
    <?php
    			$pages = wp_list_pages('sort_column=menu_order&title_li=&exclude=2,6&depth=1');
    			if ($pages) {
    			preg_match_all('/<a.*>(.*)<\/a>/', $pages, $array);
    			$asize = count($array[0]);
    			for($i = 0; $i < $asize; $i++) {
    			$link = $array[0][$i];
    			$title = $array[1][$i];
    
    			ob_start();
    			the_ttftext($array[1][$i], $echo = true, $style="menu", $overrides="");
    			$ttf = ob_get_clean();
    
    			$originalLink = $link;
    			$link = str_replace(">" . $title, ">" . $ttf, $link);
    			$pages = str_replace($originalLink, $link, $pages);
    			}
    			echo $pages;
    			}
    		?>
            </ol>

    Thoughts? Thanks

  5. alectro
    Member
    Posted 4 months ago #

    Hi lotech, is at least one of your ttf styles called menu?

  6. alectro
    Member
    Posted 4 months ago #

    Is there a way to use another style for subtitles?

  7. alectro
    Member
    Posted 4 months ago #

    I mean sub pages

Topic Closed

This topic has been closed to new replies.

About this Topic