Topic: output <?php get_parent(); ?> without hyphen in template

I need a hint how to omitt hyphen in parent ..

example:

I have a first level page "my cats"
Slug/URL is "my-cats"

Now I have a second-level-navigation in the sidebar and want to repeat the parent, like category
before the submenu

unfortunately

<?php get_parent(); ?>

outputs "my-cats" instead of "my cats"

what can I do  to omitt this?

|--
Die deutsche GetSimple-Webseite: http://www.Get-Simple.de = the german Get-Simple-Website!
Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forum/forum/16/german-deutsch/

Re: output <?php get_parent(); ?> without hyphen in template

I found a solution with Jquery:

using a jquery plugin, from http://benalman.com/projects/jquery-rep … t-plugin/, I added that code to my template:

<h2 id="replace"><?php get_parent(); ?></h2>
    <script type="text/javascript">
            $(function() {
    $("#replace").replaceText( "-", " " );  
            });
        </script>

but maybe there is a solution without additional jquery plugin?

Cheers, Connie

|--
Die deutsche GetSimple-Webseite: http://www.Get-Simple.de = the german Get-Simple-Website!
Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forum/forum/16/german-deutsch/

Re: output <?php get_parent(); ?> without hyphen in template

Just PHP:

<h2 id="replace"><?php echo str_replace('-',' ',get_parent(false)); ?></h2
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.

Re: output <?php get_parent(); ?> without hyphen in template

yes,  that is a better solution, so I don't need an additional Jquery script

but: this was my first start with Jquery, not only integrating scripts, but using it for my own purpose, so I learned!

I will include the php,  thank you!

I described this in our tipps-and-tricks-section at get-simple.de:

http://www.get-simple.de/gs-tipps-trick … destriche/

|--
Die deutsche GetSimple-Webseite: http://www.Get-Simple.de = the german Get-Simple-Website!
Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forum/forum/16/german-deutsch/

Re: output <?php get_parent(); ?> without hyphen in template

I had the same problem - but im not very happy with your solution.
You mix up URL-Slugs with navigational elements.

I tried to get the Title/Menutext of the parent page with menu_data() as following:

# output page_slug for toplevel menu entries and parent_slug for sublevel items 

#get parent Title via menu_data()
$parentdata  = menu_data(get_parent(false));

# check if PARENT title exists (>0)
if ( strlen($parentdata['title']) > 0 ) 
    {
    # show parent menu_text or fallback to title (as menu_text seems empty if same as title)
    if (strlen($parentdata['menu_text'])>0) {echo $parentdata['menu_text'];} else {echo $parentdata['title'];}
    }
    else
        {
        # or show CURRENTPAGE menu_text/title
        $seite = return_page_slug();
        $pagedata = menu_data($seite);
        if (strlen($pagedata['menu_text'])>0) {echo $pagedata['menu_text'];} else {echo $pagedata['title'];}
        }

this is doing what i want - but is there an easier way to get parent-element infos?
(sth. like "is_child" or "is_parent" would be quite helpful)

Re: output <?php get_parent(); ?> without hyphen in template

Using GS 3.1's new getPageField function:

<?php get_parent(0)!='' ? getPageField(get_parent(0),'title') : get_page_title();?>

displays parent title or current page title.