묻고답하기
확장변수 글을 태그에 자동적용하는 방법을 알려주세요!!
2017.10.24 04:25
확장변수 글을 태그에 자동적용하는 방법을 알려주세요!!
확장변수 = 다중 선택(checkbox)에 여러개글을 태그에 자동으로 입력하는 방법이 있을까요?
묻고답하기 검색해보니 아래와 같은 소스가 있는데 적용방법을 모르겠네요
https://www.xpressengine.com/index.php?mid=qna&search_target=title_content&search_keyword=%ED%99%95%EC%9E%A5%EB%B3%80%EC%88%98+%ED%83%9C%EA%B7%B8&document_srl=23087356
write_form.html 파일 어느 라인에 적용을 해야하나요?
<input type="hidden" name="tags" id="tags" value="{htmlspecialchars($oDocument->get('tags'))}" class="itx">
<script>
jQuery(function($){
$("input[name=extra_vars2]").keyup(function(){
//$('#extra_vars2').keyup(function(){
text_copy=$(this).val();
$('#tags').val(text_copy);
});
});
</script>
댓글 4
-
배워서남준다
2017.10.24 09:20
-
uppylook
2017.10.24 12:49
위에 경로 소스를 적용을 이렇게 해봤는데 안되더라고요 ^^
확장변수는 extra_vars2 이렇게 넣었구요
<form cond="!Mobile::isMobileCheckByAgent() || $mi->m_editor==3" action="./" method="post" onsubmit="return procFilter(this, window.insert)" class="bd_wrt bd_wrt_main clear">
<input type="hidden" name="mid" value="{$mid}" />
<!--@if($oDocument->getContentText())-->
<input type="hidden" name="content" value="{$oDocument->getContentText()}" />
<!--@else-->
<input type="hidden" name="content" value="{htmlspecialchars($mi->content_default)}" />
<!--@end-->
<input type="hidden" name="document_srl" value="{$document_srl}" />
<!--// 소스보고 추가적용 문구 -->
<input type="hidden" name="tags" id="tags" value="{htmlspecialchars($oDocument->get('tags'))}" class="itx">
<!--// 상단 : 카테고리, 제목 -->
<table class="bd_wrt_hd bd_tb">
<tr>
<td>
<select cond="$mi->use_category=='Y' && $category_list" name="category_srl" class="category">
<option value="">{$lang->category}</option>
<option loop="$category_list => $val" disabled="disabled"|cond="!$val->grant" value="{$val->category_srl}" selected="selected"|cond="$val->grant&&$val->selected||$val->category_srl==$oDocument->get('category_srl')">
{str_repeat(" ",$val->depth)} {$val->title} ({$val->document_count})
</option>
</select>
</td>
<td width="100%">
<span class="itx_wrp">
<label for="postTitle">{$lang->title}</label>
<input type="text" name="title" class="itx" id="postTitle" title="{$lang->title}" value="{htmlspecialchars($oDocument->getTitleText())}"|cond="$oDocument->getTitleText()" />
</span>
</td>
<td cond="$is_logged && !$oDocument->isExists() || $oDocument->get('status')=='TEMP'" class="m_no"><button type="button" class="bd_btn" onclick="doDocumentLoad(this);">{$lang->cmd_load}</button></td>
</tr>
</table>
<table cond="count($extra_keys)" class="et_vars exForm bd_tb">
<caption><strong><em>*</em></strong> <small>: {$lang->is_required}</small></caption>
<!--// 소스보고 추가적용 문구 -->
<tr loop="$extra_keys=>$key,$val" id="tags"|cond="$val->name=='extra_vars2'">
<th scope="row"><em cond="$val->is_required=='Y'">*</em> {$val->name}</th>
<td>{$val->getFormHTML()}</td>
</tr>
</table>
<div class="get_editor">{$oDocument->getEditor()}</div>
<!--// 소스보고 추가적용 문구 -->
<script>
jQuery(function($){
$("input[name=extra_vars2]").keyup(function(){
//$('#extra_vars2').keyup(function(){
text_copy=$(this).val();
$('#tags').val(text_copy);
});
});
</script>
<!--// 태그 -->
<div class="tag itx_wrp">
<span class="itx_wrp">
<label for="tags">{$lang->tag} : {$lang->about_tag}</label>
<input type="text" name="tags" id="tags" value="{htmlspecialchars($oDocument->get('tags'))}" class="itx"/>
</span>
</div>
-
배워서남준다
2017.10.24 14:22
<include target="_header.html" /> <form action="./" method="post" onsubmit="return procFilter(this, window.insert)" class="board_write"> <input type="hidden" name="mid" value="{$mid}" /> <input type="hidden" name="content" value="{$oDocument->getContentText()}" /> <input type="hidden" name="document_srl" value="{$document_srl}" /> <div class="write_header"> <select name="category_srl" cond="$module_info->use_category=='Y'"> <option value="">{$lang->category}</option> <option loop="$category_list => $val" disabled="disabled"|cond="!$val->grant" value="{$val->category_srl}" selected="selected"|cond="$val->grant&&$val->selected||$val->category_srl==$oDocument->get('category_srl')"> {str_repeat(" ",$val->depth)} {$val->title} ({$val->document_count}) </option> </select> <input cond="$oDocument->getTitleText()" type="text" name="title" class="iText" title="{$lang->title}" value="{htmlspecialchars($oDocument->getTitleText())}" /> <input cond="!$oDocument->getTitleText()" type="text" name="title" class="iText" title="{$lang->title}" /> <input cond="$grant->manager" type="checkbox" name="is_notice" value="Y" class="iCheck" checked="checked"|cond="$oDocument->isNotice()" id="is_notice" /> <label cond="$grant->manager" for="is_notice">{$lang->notice}</label> </div> <div class="exForm" cond="count($extra_keys)"> <table cond="count($extra_keys)" border="1" cellspacing="0" summary="Extra Form"> <caption><em>*</em> : {$lang->is_required}</caption> <tr loop="$extra_keys=>$key,$val"> <th scope="row"><em cond="$val->is_required=='Y'">*</em> {$val->name}</th> <td>{$val->getFormHTML()}</td> </tr> </table> </div> <div class="write_editor"> {$oDocument->getEditor()} </div> <div class="write_footer"> <div class="write_option"> <block cond="$grant->manager"> <input type="checkbox" name="title_bold" id="title_bold" class="iCheck" value="Y" checked="checked"|cond="$oDocument->get('title_bold')=='Y'" /> <label for="title_bold">{$lang->title_bold}</label> </block> <input cond="$module_info->secret=='Y'" type="checkbox" name="is_secret" class="iCheck" value="Y" checked="checked"|cond="$oDocument->isSecret()" id="is_secret" /> <label cond="$module_info->secret=='Y'" for="is_secret">{$lang->secret}</label> <input type="checkbox" name="comment_status" class="iCheck" value="ALLOW" checked="checked"|cond="$oDocument->allowComment()" id="comment_status" /> <label for="comment_status">{$lang->allow_comment}</label> <input type="checkbox" name="allow_trackback" class="iCheck" value="Y" checked="checked"|cond="$oDocument->allowTrackback()" id="allow_trackback" /> <label for="allow_trackback">{$lang->allow_trackback}</label> <block cond="$is_logged"> <input type="checkbox" name="notify_message" class="iCheck" value="Y" checked="checked"|cond="$oDocument->useNotify()" id="notify_message" /> <label for="notify_message">{$lang->notify}</label> </block> <!--@if(is_array($status_list))--> <!--@foreach($status_list AS $key=>$value)--> <input type="radio" name="status" value="{$key}" id="{$key}" <!--@if($oDocument->get('status') == $key || ($key == 'PUBLIC' && !$document_srl))-->checked="checked"<!--@end--> /> <label for="{$key}">{$value}</label> <!--@end--> <!--@end--> </div> <div class="write_author"> <span class="item" cond="!$is_logged"> <label for="userName" class="iLabel">{$lang->writer}</label> <input type="text" name="nick_name" id="userName" class="iText userName" style="width:80px" value="{htmlspecialchars($oDocument->get('nick_name'))}" /> </span> <span class="item" cond="!$is_logged"> <label for="userPw" class="iLabel">{$lang->password}</label> <input type="password" name="password" id="userPw" class="iText userPw" style="width:80px" /> </span> <span class="item" cond="!$is_logged"> <label for="homePage" class="iLabel">{$lang->homepage}</label> <input type="text" name="homepage" id="homePage" class="iText homePage" style="width:140px"value="{htmlspecialchars($oDocument->get('homepage'))}" /> </span> <span class="item"> <label for="tags" class="iLabel">{$lang->tag}: {$lang->about_tag}</label> <input type="text" name="tags" id="tags" value="{htmlspecialchars($oDocument->get('tags'))}" class="iText" style="width:300px" title="Tag" /> </span> </div> <div class="btnArea"> <block cond="!$oDocument->isExists() || $oDocument->get('status') == 'TEMP'"> <button cond="$is_logged" class="btn" type="button" onclick="doDocumentSave(this);">{$lang->cmd_temp_save}</button> <button cond="$is_logged" class="btn" type="button" onclick="doDocumentLoad(this);">{$lang->cmd_load}</button> </block> <button type="submit" class="btn_insert"><i class="xi-pen"></i> {$lang->cmd_registration}</button> </div> </div> </form> <include target="_footer.html" /> <script> jQuery(function($){ $("input[name=extra_vars1]").keyup(function(){ text_copy=$(this).val(); $('#tags').val(text_copy); }); }); </script>
잘못 알려드렸네요.
input[name=extra_vars2] 가 아니라 input[name=extra_vars1] 으로 해보세요.
확장변수 입력항목이 1개인경우 extra_vars1 으로 해야합니다.
스크립트만 제일 하단에 복사해서 붙여넣고 extra_vars1 으로 바꿔주었더니 전 잘 작동했습니다.
-
uppylook
2017.10.24 16:27
스케치북을 사용하고 있고요, 다른데는 손을 안데고요 알려주신 스크립트만 복사해서 아래에 넣었습니다. 그리고 게시판 확장명을 이름을 extra_vars1 이렇게 넣었고요 안되네요, 어찌 해야하나요 가르침 부탁드립니다. 감사합니다.
<include target="_header.html" />
<load target="js/editor.js" type="body" />
<include cond="Mobile::isMobileCheckByAgent() && $mi->m_editor!=3" target="_write_form_mobile.html" />
<form cond="!Mobile::isMobileCheckByAgent() || $mi->m_editor==3" action="./" method="post" onsubmit="return procFilter(this, window.insert)" class="bd_wrt bd_wrt_main clear">
<input type="hidden" name="mid" value="{$mid}" />
<!--@if($oDocument->getContentText())-->
<input type="hidden" name="content" value="{$oDocument->getContentText()}" />
<!--@else-->
<input type="hidden" name="content" value="{htmlspecialchars($mi->content_default)}" />
<!--@end-->
<input type="hidden" name="document_srl" value="{$document_srl}" />
<!--// 상단 : 카테고리, 제목 -->
<table class="bd_wrt_hd bd_tb">
<tr>
<td>
<select cond="$mi->use_category=='Y' && $category_list" name="category_srl" class="category">
<option value="">{$lang->category}</option>
<option loop="$category_list => $val" disabled="disabled"|cond="!$val->grant" value="{$val->category_srl}" selected="selected"|cond="$val->grant&&$val->selected||$val->category_srl==$oDocument->get('category_srl')">
{str_repeat(" ",$val->depth)} {$val->title} ({$val->document_count})
</option>
</select>
</td>
<td width="100%">
<span class="itx_wrp">
<label for="postTitle">{$lang->title}</label>
<input type="text" name="title" class="itx" id="postTitle" title="{$lang->title}" value="{htmlspecialchars($oDocument->getTitleText())}"|cond="$oDocument->getTitleText()" />
</span>
</td>
<td cond="$is_logged && !$oDocument->isExists() || $oDocument->get('status')=='TEMP'" class="m_no"><button type="button" class="bd_btn" onclick="doDocumentLoad(this);">{$lang->cmd_load}</button></td>
</tr>
</table>
<table cond="count($extra_keys)" class="et_vars exForm bd_tb">
<caption><strong><em>*</em></strong> <small>: {$lang->is_required}</small></caption>
<tr loop="$extra_keys=>$key,$val">
<th scope="row"><em cond="$val->is_required=='Y'">*</em> {$val->name}</th>
<td>{$val->getFormHTML()}</td>
</tr>
</table>
<div class="get_editor">{$oDocument->getEditor()}</div>
<!--// 태그 -->
<div class="tag itx_wrp">
<span class="itx_wrp">
<label for="tags">{$lang->tag} : {$lang->about_tag}</label>
<input type="text" name="tags" id="tags" value="{htmlspecialchars($oDocument->get('tags'))}" class="itx"/>
</span>
</div>
<!--// 비로그인 입력 -->
<div class="edit_opt">
<block cond="!$is_logged">
<span class="itx_wrp">
<label for="nick_name">{$lang->writer}</label>
<input type="text" name="nick_name" id="nick_name" value="{$oDocument->getNickName()}" class="itx n_p" />
</span>
<span class="itx_wrp">
<label for="password">{$lang->password}</label>
<input type="password" name="password" id="password" class="itx n_p" />
</span>
<span class="itx_wrp">
<label for="email_address">{$lang->email_address}</label>
<input type="text" name="email_address" id="email_address" value="{htmlspecialchars($oDocument->get('email_address'))}" class="itx m_h" />
</span>
<span class="itx_wrp">
<label for="homepage">{$lang->homepage}</label>
<input type="text" name="homepage" id="homepage" value="{htmlspecialchars($oDocument->get('homepage'))}" class="itx m_h" />
</span>
</block>
</div>
<!--// 글쓰기 옵션 체크 -->
<div class="opt_chk clear">
<div cond="$grant->manager || $mi->tl_color=='2'" class="section">
<!--%load_js_plugin("ui.colorpicker")-->
<span class="itx_wrp color_wrp" title="{$lang->title_color}">
<label for="title_color">{$lang->title_color}</label>
<input type="text" name="title_color" id="title_color" class="itx color-indicator" value="{$oDocument->get('title_color')}"|cond="$oDocument->get('title_color')!='N'" />
</span>
<input type="checkbox" name="title_bold" id="title_bold" value="Y" checked="checked"|cond="$oDocument->get('title_bold')=='Y'" />
<label for="title_bold">{$lang->title_bold}</label>
<block cond="$grant->manager">
<input type="checkbox" name="is_notice" value="Y" checked="checked"|cond="$oDocument->isNotice()" id="is_notice" />
<label for="is_notice">{$lang->notice}</label>
</block>
</div>
<div class="section">
<input type="checkbox" name="comment_status" value="ALLOW" checked="checked"|cond="$oDocument->allowComment()" id="comment_status" />
<label for="comment_status">{$lang->allow_comment}</label>
<input type="checkbox" name="allow_trackback" value="Y" checked="checked"|cond="$oDocument->allowTrackback()" id="allow_trackback" />
<label for="allow_trackback">{$lang->allow_trackback}</label>
</div>
<div cond="$is_logged" class="section">
<input type="checkbox" name="notify_message" value="Y" checked="checked"|cond="$oDocument->useNotify() || (!$oDocument->useNotify() && @in_array('notify',$mi->wrt_opt))" id="notify_message" />
<label for="notify_message">{$lang->notify}</label>
</div>
<div cond="is_array($status_list)" class="section">
<!--@foreach($status_list AS $key=>$value)-->
<input cond="@!in_array('secret',$mi->wrt_opt)" type="radio" name="status" value="{$key}" id="{$key}" checked="checked"|cond="$oDocument->get('status')==$key || ($key=='PUBLIC' && !$document_srl)" />
<input cond="@in_array('secret',$mi->wrt_opt)" type="radio" name="status" value="{$key}" id="{$key}" checked="checked"|cond="$oDocument->get('status')==$key || ($key=='SECRET' && !$document_srl)" />
<label for="{$key}">{$value}</label>
<!--@end-->
</div>
</div>
<!--// SocialXE -->
<div cond="$mi->cmt_wrt=='sns'" class="sns_wrt">
<p>※ {$lang->sns_wrt}.</p>
<img class="zbxe_widget_output" widget="socialxe_info" colorset="{$mi->colorset}" skin="default" />
</div>
<!--// Buttons -->
<div class="regist">
<button cond="$is_logged && !$oDocument->isExists() || $oDocument->get('status')=='TEMP'" type="button" onclick="doDocumentSave(this);" class="bd_btn temp">{$lang->cmd_temp_save}</button>
<input type="button" value="{$lang->cmd_preview}" onclick="doDocumentPreview(this);return false" class="bd_btn m_no" />
<input type="submit" value="{$lang->cmd_submit}" class="bd_btn blue" />
<button type="button" onclick="history.back()" class="bd_btn cancle">{$lang->cmd_back}</button>
</div>
</form>
</div>
<script>
jQuery(function($){
$("input[name=extra_vars1]").keyup(function(){
text_copy=$(this).val();
$('#tags').val(text_copy);
});
});
</script>
적용을 안해보았지만, 위 코드대로 사용하려면 확장변수명을 extra_vars2 으로 지정하셔야 할것 같아요.