Quickpost Title

| Filed under Hacks

It's been a while since I posted a hack so here's a quick one. Someone on ProNet asked how, whilst quickposting, to have the title of the page appear in the Entry Title field instead of/as well as the Entry Body field.

This is quite simple, in lib/MT/App/CMS.pm, around line 905, find

 $param{text} = sprintf qq(<a title="%s" href="%s">%s</a>\n\n%s),
                        scalar $q->param('link_title'),
                        scalar $q->param('link_href'),
                        scalar $q->param('link_title'),
                        $param{text};

The next step depends on what you want. If you want the link title to appear in the Entry Title field and nothing in the Entry Body, then replace the above code with what is below. If you want the Entry Body field to remain as is but want the link title to appear in the Entry Title field too then just add the code below to the next line.

 $param{text} = sprintf qq(<a title="%s" href="%s">%s</a>\n\n%s),
                        scalar $q->param('link_title'),
                        scalar $q->param('link_href'),
                        scalar $q->param('link_title'),
                        $param{text};
 $param{title} = scalar $q->param('link_title');

In a similar fashion you can manipulate other elements of the page. Open up bm_entry.tmpl and browse through the HTML of the page. The import bits are the names of the variables used, for example

<TMPL_VAR NAME=TITLE ESCAPE=HTML>

You can set the value of any of these in CMS.pm, in the same section as above, just use $param{title} where "title" is the name of the variable. You can of course add your own, for example if you wanted something to appear in the Extended Entry textarea, you would add the following in between the textarea

<TMPL_VAR NAME=TEXT_MORE ESCAPE=HTML>

and in CMS.pm, you'd define the text_more variable:

 $param{text} = sprintf qq(<a title="%s" href="%s">%s</a>\n\n%s),
                        scalar $q->param('link_title'),
                        scalar $q->param('link_href'),
                        scalar $q->param('link_title'),
                        $param{text};
 $param{title} = scalar $q->param('link_title'); 
 $param{text_more} = "This will show in the Extended Entry";