1 of 2
1
Dynamic Title and URL Title
Posted: 09 November 2010 01:13 AM   [ Ignore ]
Has a Great Personality
Rank
Total Posts:  41
Joined  2010-11-08

Hi

My current form is as follows

{exp:safecracker channel="fixtures" 
    
return="fixtures/thanks_row" 
    
datepicker="no"
}
<fieldset>
<
input type="hidden" name="allow_comments" value="n" />
<
input type="hidden" name="status" value="Pending" />
<
table cellspacing="0">
    <
tr>
        <
td>
            <
input type="text" name="entry_date" id="entry_date" value="{current_time format='%Y-%m-%d %H:%i'}" maxlength="23" size="16" /> 
            <
input type="text" name="title" id="title" value="{title}" maxlength="100"
            <
input type="hidden" name="url_title"  id="url_title" value="{url_title}" maxlength="75" />
            <
select name="category[]">
                <
option value="" selected="selected">--</option>
                
{exp:channel:categories cache="yes" channel="seasons" refresh="60" style="linear"}
                {if parent_id
=='0'}<optgroup label="{category_name}">
                
{if:else}<option value="{category_id}">{category_name}
                {
/if}
                {if parent_id
=='0'}</optgroup>
                
{if:else}</option>
                
{/if}
                {
/exp:channel:categories}
            
</select>
        </
td>
    </
tr>
    <
tr>
        <
td>
            
{field:fixture_home_team} {field:fixture_away_team} 
            
<button type="submit" name="submit">Submit</button>
        </
td>
    </
tr>
</
table>
</
fieldset>
{/exp:safecracker} 

I would like to have both the title and the url title dynamically added using the {field:fixture_home_team} and {field:fixture_away_team} is that possible.

Thanks

Profile
 
 
Posted: 09 November 2010 03:36 AM   [ Ignore ]   [ # 1 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

Sure, first remove the title and the url title hidden inputs. Then use the dynamic_title parameter: http://barrettnewton.com/safecracker/user_guide/entry_form/#par_dynamic_title

{exp:safecracker channel="fixtures"
    
dynamic_title="[fixture_home_team] [fixture_away_team]" 
Profile
 
 
Posted: 09 November 2010 03:41 AM   [ Ignore ]   [ # 2 ]
Has a Great Personality
Rank
Total Posts:  41
Joined  2010-11-08
Rob Sanchez - 09 November 2010 03:36 AM

Sure, first remove the title and the url title hidden inputs. Then use the dynamic_title parameter: http://barrettnewton.com/safecracker/user_guide/entry_form/#par_dynamic_title

{exp:safecracker channel="fixtures"
    
dynamic_title="[fixture_home_team] [fixture_away_team]" 

Because these are related entries I get the entry ID instead of the entry title for the fixture_home_team and fixture_away_team so the title is 2 1

Profile
 
 
Posted: 09 November 2010 03:44 AM   [ Ignore ]   [ # 3 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

I see. Well, then I’d recommend either a) manipulating a hidden title input on the form submit using javascript, or b) writing an extension to handle this using one of these extension hooks http://barrettnewton.com/safecracker/user_guide/development/#section_hooks

Profile
 
 
Posted: 09 November 2010 03:46 AM   [ Ignore ]   [ # 4 ]
Has a Great Personality
Rank
Total Posts:  41
Joined  2010-11-08
Rob Sanchez - 09 November 2010 03:44 AM

I see. Well, then I’d recommend either a) manipulating a hidden title input on the form submit using javascript, or b) writing an extension to handle this using one of these extension hooks http://barrettnewton.com/safecracker/user_guide/development/#section_hooks

Rob, thanks for the advice, both those are beyond my knowledge at the moment.

Profile
 
 
Posted: 09 November 2010 03:47 AM   [ Ignore ]   [ # 5 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

What is the field type of those fields?

Profile
 
 
Posted: 09 November 2010 03:49 AM   [ Ignore ]   [ # 6 ]
Has a Great Personality
Rank
Total Posts:  41
Joined  2010-11-08

They are relationship fields

Profile
 
 
Posted: 09 November 2010 03:56 AM   [ Ignore ]   [ # 7 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

Try some javascript like this, assuming you have jQuery loaded:

script type="text/javascript" >
$(
document).ready(function(){
    
$('#publishForm').submit(function(){
        
$('input[name=title]').val( $('select[name=fixture_home_team] option:selected').text() + ' ' + $('select[name=fixture_away_team] option:selected').text() );
    
});
});
< /
script 
[ Edited: 09 November 2010 04:48 AM by Rob Sanchez ]
Profile
 
 
Posted: 09 November 2010 04:47 AM   [ Ignore ]   [ # 8 ]
Has a Great Personality
Rank
Total Posts:  41
Joined  2010-11-08

Rob sorry for being a pain but where do I place that code, thanks.

Profile
 
 
Posted: 09 November 2010 04:49 AM   [ Ignore ]   [ # 9 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

That should go into your <head>. Don’t forget to fix the script tags if you copy directly from my example. And make sure you have a hidden title input.

Profile
 
 
Posted: 09 November 2010 04:55 AM   [ Ignore ]   [ # 10 ]
Has a Great Personality
Rank
Total Posts:  41
Joined  2010-11-08
Rob Sanchez - 09 November 2010 04:49 AM

That should go into your <head>. Don’t forget to fix the script tags if you copy directly from my example. And make sure you have a hidden title input.

I had it in there but only after I posted that reply that show the script tags.

For the hidden title input do you mean

<input type="hidden" name="title"  id="title" value="{title}"  /> 
Profile
 
 
Posted: 09 November 2010 04:56 AM   [ Ignore ]   [ # 11 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

Yep, that’s what I mean.

Profile
 
 
Posted: 09 November 2010 04:58 AM   [ Ignore ]   [ # 12 ]
Has a Great Personality
Rank
Total Posts:  41
Joined  2010-11-08

I’m not getting anything in the Title now.

Profile
 
 
Posted: 10 November 2010 04:10 AM   [ Ignore ]   [ # 13 ]
Has a Great Personality
Rank
Total Posts:  41
Joined  2010-11-08

Rob

Sorry to be a pain, would you have any ideas why that code doesn’t work.

Cheers

Profile
 
 
Posted: 10 November 2010 04:13 AM   [ Ignore ]   [ # 14 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

Are you getting any javascript errors in your console? Can you post the HTML source of your entry form page?

Profile
 
 
Posted: 10 November 2010 04:17 AM   [ Ignore ]   [ # 15 ]
Has a Great Personality
Rank
Total Posts:  41
Joined  2010-11-08

There are two parts to the page this is the main part.

<!DOCTYPE html>
<
html lang="en">
<
head>
    <
meta charset="utf-8"/>
    <
title>Publish Fixtures NIFootball</title>
    <
meta name="description" content="" />
    <
meta name="keywords" content="" />
    <
meta name="author" content="Copyright Scott Boyde, NIFootball. All rights reserved." />
    <
link rel="alternate" type="application/rss+xml" title="NIFootball" href="http://localhost/www.nifootball.co.uk/index.php/_rss" />

<
link rel="icon" type="image/ico" href="/favicon.ico" />
<
link rel="stylesheet" type="text/css" href="http://localhost/www.nifootball.co.uk/index.php?css=_css/index.v.1289242967" />
    
<!--
[if IE]>
[removed][removed]
<![endif]-->
    
[removed][removed]
[removed][removed]

</head>
<
body>

<
div class="box">
    <
header>
        <
h1><span></span>Publish league Fixtures</h1>

    </
header>
    
    <
p><a href="http://localhost/www.nifootball.co.uk/index.php/fixtures">Go back to Fixtures</a></p>
    
        
        <
div><iframe src="http://localhost/www.nifootball.co.uk/index.php/fixtures/publish_row_league" frameborder="0" height="80" marginheight="0" marginwidth="0" scrolling="auto" width="100%"><p>Your browser does not support iframes.</p></iframe></div>
    <
div><iframe src="http://localhost/www.nifootball.co.uk/index.php/fixtures/publish_row_league" frameborder="0" height="80" marginheight="0" marginwidth="0" scrolling="auto" width="100%"><p>Your browser does not support iframes.</p></iframe></div>
    <
div><iframe src="http://localhost/www.nifootball.co.uk/index.php/fixtures/publish_row_league" frameborder="0" height="80" marginheight="0" marginwidth="0" scrolling="auto" width="100%"><p>Your browser does not support iframes.</p></iframe></div>
    <
div><iframe src="http://localhost/www.nifootball.co.uk/index.php/fixtures/publish_row_league" frameborder="0" height="80" marginheight="0" marginwidth="0" scrolling="auto" width="100%"><p>Your browser does not support iframes.</p></iframe></div>

    <
div><iframe src="http://localhost/www.nifootball.co.uk/index.php/fixtures/publish_row_league" frameborder="0" height="80" marginheight="0" marginwidth="0" scrolling="auto" width="100%"><p>Your browser does not support iframes.</p></iframe></div>
    <
div><iframe src="http://localhost/www.nifootball.co.uk/index.php/fixtures/publish_row_league" frameborder="0" height="80" marginheight="0" marginwidth="0" scrolling="auto" width="100%"><p>Your browser does not support iframes.</p></iframe></div>
    <
div><iframe src="http://localhost/www.nifootball.co.uk/index.php/fixtures/publish_row_league" frameborder="0" height="80" marginheight="0" marginwidth="0" scrolling="auto" width="100%"><p>Your browser does not support iframes.</p></iframe></div>
    <
div><iframe src="http://localhost/www.nifootball.co.uk/index.php/fixtures/publish_row_league" frameborder="0" height="80" marginheight="0" marginwidth="0" scrolling="auto" width="100%"><p>Your browser does not support iframes.</p></iframe></div>
    <
div><iframe src="http://localhost/www.nifootball.co.uk/index.php/fixtures/publish_row_league" frameborder="0" height="80" marginheight="0" marginwidth="0" scrolling="auto" width="100%"><p>Your browser does not support iframes.</p></iframe></div>
    <
div><iframe src="http://localhost/www.nifootball.co.uk/index.php/fixtures/publish_row_league" frameborder="0" height="80" marginheight="0" marginwidth="0" scrolling="auto" width="100%"><p>Your browser does not support iframes.</p></iframe></div>

    <
p><a href="http://localhost/www.nifootball.co.uk/index.php/fixtures/publish">Load 10 new publish frames</a></p>

        
    
</
div>

</
body>
</
html
Profile
 
 
   
1 of 2
1