How do I get accurate entry paths in Expression Engine search results? - expressionengine

I am working to implement advanced search on a site and need some help getting more accurate paths to entries in the search results page.
I am using a modified advanced search form:
{exp:search:advanced_form result_page="search/advanced_results"}
<fieldset class="fieldset">
<legend>{lang:search_by_keyword}</legend>
<input type="text" class="input" maxlength="100" size="40" name="keywords" style="width:100%;" />
<div class="default">
<select name="search_in">
<option value="titles" selected="selected">{lang:search_in_titles}</option>
<option value="entries" selected="selected">{lang:search_in_entries}</option>
</select>
</div>
<div class="default">
<select name="where">
<option value="exact" selected="selected">{lang:exact_phrase_match}</option>
<option value="any">{lang:search_any_words}</option>
<option value="all" >{lang:search_all_words}</option>
<option value="word" >{lang:search_exact_word}</option>
</select>
</div>
</fieldset>
<div class="defaultBold">{lang:channels}</div>
<select id="channel_id" name='channel_id[]' class='multiselect' size='15' multiple='multiple' onchange='changemenu(this.selectedIndex);'>
{channel_names}
</select>
<div class="defaultBold">{lang:categories}</div>
<select name='cat_id[]' size='18' class='multiselect' multiple='multiple'>
<option value='all' selected="selected">{lang:any_category}</option>
</select>
<div class='searchSubmit'>
<input type='submit' value='Search' class='submit' />
</div>
{/exp:search:advanced_form}
</body>
and the standard search results code:
<table border="0" cellpadding="6" cellspacing="1" width="100%">
<tr>
<th>{lang:title}</th>
<th>{lang:excerpt}</th>
<th>{lang:author}</th>
<th>{lang:date}</th>
<th>{lang:total_comments}</th>
<th>{lang:recent_comments}</th>
</tr>
{exp:search:search_results switch="resultRowOne|resultRowTwo"}
<tr class="{switch}">
<td width="30%" valign="top"><b>{title}</b></td>
<td width="30%" valign="top">{excerpt}</td>
<td width="10%" valign="top">{author}</td>
<td width="10%" valign="top">{entry_date format="%m/%d/%y"}</td>
<td width="10%" valign="top">{comment_total}</td>
<td width="10%" valign="top">{recent_comment_date format="%m/%d/%y"}</td>
</tr>
{/exp:search:search_results}
</table>
The only problem is that the {auto_path} is anything but accurate, does not link to the entry and basically tries to piggyback off the home page. Is there a way secure more accurate paths? I know Google Search can do it.
Thanks!

Admin → Channel Administration → Channels → Edit Preferences → Path Settings. There you enter the base URL for your auto_path or id_auto_path.
So entering /news/entry/ would yield /news/entry/my-new-url-title in your search results.

The {auto_path} variable in the Search Results Tag is automatically be determined by the Search Results URL preference setting for the channel in Channel Management.
You can find this preference in the Control Panel at: Admin > Channel Administration > Channel Preferences:

Related

How to do I pass unique identifier from button to Modal in Handlebars?

I'm creating a Accounting Web System using Nodejs and Express with Handlebars (.hbs), while using Bootstrap as my main Frontend toolkit. I have a dynamic table with each row consisting of information and three buttons. With delete button ("eliminar"), I'm adding a modal to verify that the user actually wants to delete information instead of by accident.
However, when inserting the modal into my handlebar, the information no longer belongs to its appropriate row but rather the first row from the query object rendered into the handlebar. My code looks like this:
<table class="table table-bordered">
<thead class="thead-dark text-center">
<tr>
<th scope="col">Tipo ID</th>
<th scope="col">Tipo Codigo</th>
<th scope="col">Tipo Descripcion</th>
<th scope="col">Acciones</th>
<th scope="col">Usuario</th>
{{!-- <th scope="col">Tiempo Creado:</th> --}}
</tr>
</thead>
<tbody class="text-center">
{{#each tipoparametro}}
<tr>
<th scope="row">{{this.tipoparid}}</th>
<td>{{this.tipoparcodigo}}</td>
<td>{{this.tipodescripcion}}</td>
<td class="text-center">
<a href="/viewuser/{{this.tipoparid}}" type="button" class="btn btn-outline-info btn-small"><i
class="bi bi-eye"></i>Ver</a>
<a href="/edituser/{{this.tipoparid}}" type="button" class="btn btn-outline-primary btn-small"><i
class="bi bi-pencil"></i>Modificar</a>
<a href="/delete/{{this.tipoparid}}" type="button" class="btn btn-outline-danger btn-small"
value={{this.tipoparid}} data-bs-toggle="modal" data-bs-target="#staticBackdrop"
data-target={{this.tipoparid}}><i class="bi bi-person-x"></i>Eliminar - {{this.tipoparid}}</a>
</td>
{{!-- New --}}
<!-- Modal -->
<div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
aria-labelledby="staticBackdropLabel" aria-hidden="true" value={{this.tipoparid}}>
<div class="modal-dialog text-center">
<div class="modal-content">
<div class="modal-header text-center">
<h5 class="modal-title w-100" id="staticBackdropLabel">Eliminar
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body ">
Estas seguro que quieres eliminar este Tipo Parametro:
<hr>
<p class="card-text"><strong>Id:</strong> {{this.tipoparid}}</p>
<p class="card-text"><strong>Codigo de Parametro:</strong> {{this.tipoparcodigo}}</p>
<p class="card-text"><strong>Usuario:</strong> {{this.usuarionombre}}</p>
<p class="card-text"><strong>Descripcion:</strong> {{this.tipodescripcion}}</p>
</div>
<div class="modal-footer d-flex justify-content-between">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cerrar</button>
<a type="button" class="btn btn-outline-danger yes" href="/delete/{{this.tipoparid}}">Eliminar</a>
</div>
</div>
</div>
</div>
{{!-- New --}}
<td>{{this.usuarionombre}}</td>
</tr>
{{/each}}
</tbody>
</table>
Is there a simplified way to pass the unique identifier this.tipoparid into the modal so I can obtain the correct info from each row and not from the first all the time?
It's important for me to output the information inside the modal according to its row.

How to sent an id outside the loop of handlebars to the form inside the handlebars?

<form method="POST" action="/admin/update-blog/{{blogs._id}}">
<div class="form-group">
<label for="exampleInputPassword1">HEADING</label>
<input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" value="{{blogs.heading}}" name="heading">
</div>
<br><br>
<div class="form-group">
<label for="exampleInputPassword1">BLOG</label>
<input type="text" class="form-control" id="exampleInputPassword1" value="{{blogs.blog}}" name="blog">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<br><br>
<h2><i><b>Comments</b></i></h2>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Email</th>
<th scope="col">Message</th>
</tr>
</thead>
<tbody>
{{#each blogs.comments}}
<tr>
<th scope="row"></th>
<td>
<form method="POST" action="/admin/delete-comment">
<div class="form-group">
<label for="exampleInputEmail1"></label>
<input type="email" class="form-control" id="myInput"readonly aria-describedby="emailHelp" placeholder="Enter email" value="{{this.email}}" name="email">
</div>
<button type="submit" class="btn btn-danger">delete</button>
</form>
</td>
<td>{{this.message}}</td>
</tr>
{{/each}}
</tbody>
</table>
How can i pass the {{blogs._id}} to a form which is inside a loop called {{#each blogs.comments}} .Is that possible.I am trying to delete a comment based on the email and the id of blog.Here the blog id is there in the top of code which is the first form where it displays the blog .And in the second form it displays the comments for the blog.
For me it is not possible to pass the id from blog to second loop(display comment).
I want to pass the id of blog to the action of the form in second loop(display comment)
THANKS IN ADVANCE😊
<option value="{{id}}">{{title}} {{../externalValue}}</option>
//The ../ path segment references the parent template scope that should be what you want.

How to get input field embedded in table using page-object accessor

Given the HTML snippet below how can I, using page-object field accessors, get the second input field, the one with id="333:".
I can't use the id to identify the field as it's auto-generated.
Using page-object accessors I can get the embedded table and the correct cell but the cell object is a PageObject::Elements::TableCell which doesn't seem to have any methods that allow access to the embedded span and input field.
I can get the input field using native Watir accessors - i.e., browser.div( ... etc ...) but would prefer to use just page-object accessors if possible.
If not possible then I'll live with native Watir. Thanks
<div class="modalContent">
<table role="presentation" id="324:_layoutTbl" class="axial">
<tbody>
<tr>
<td>
<input id="326:" name="" value="" onchange="juic.fire("326:","_change",event);" onfocus="juic.fire("326:","_focus",event);" onblur="juic.fire("326:","_blur",event);" type="text">
</td>
</tr>
<tr>
<td class="sfTH">
<label for="332:">Users:</label>
</td>
<td>
<table class="noborder" role="presentation">
<tbody>
<tr>
<th>
<label id="336:" class="rcmFormLabel">Hiring Manager</label>
<label id="337:" for="333:" class="rcmFormLabe">Users, Hiring Manager</label>
</th>
<td><span class="autocompspan ">
<input class="autocompinput" id="333:" name="333:" onfocus="juic.fire("333:","_focus",event);" size="20" value="Bill Murray" role="combobox" type="text">
<input value="111111" id="333:_hidden" name="333:_hidden" type="hidden">
</span>
<div id="335:" style="display:none"><img alt="" class="globalFloatLeft">
<div id="335:_error" style="color:#ff0000">undefined is required</div>
<div style="clear:both;"></div>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
After more experimenting I found the answer to my question. I declared the table accessor, e.g., div(:my_table, :class => 'modalContent').table.table then in the code, to get the input field in the first row I did my_text_field = my_table_element[0].text_field_element which returned the PageObject::TextField object in column 2 of row 1

SharePoint2k7: Custom List EditForm annoying field labels, how to remove?

I experienced some 'strange' differences on SharePoint 2007 between my TST and PRD environment. I was working on customising a list's EditForm, and I noticed the new form I created on TST displayed correctly like this:
This is the style I wanted. However, when I performed exactly same operation on the PRD, this was what I got, note the extra form field labels and wrappers around the same two fields:
The source (of the generated html files) were different too:
Correctly displayed:
<tr><td width="190px" valign="top" class="ms-formlabel"><H3 class="ms-standardheader"><nobr>Profit Centre<span class="ms-formvalidation"> *</span></nobr></H3></td>
<td width="400px" valign="top" class="ms-formbody"><span dir="none">
<input name="ctl00$m$g_193d5406_ba72_454b_b14c_87873ba714d6$ff5_1$ctl00$ctl00$TextField" type="text" value="ALL" maxlength="255" id="ctl00_m_g_193d5406_ba72_454b_b14c_87873ba714d6_ff5_1_ctl00_ctl00_TextField" title="Profit Centre" class="ms-long" /><br>
</span></td></tr>
<tr><td width="190px" valign="top" class="ms-formlabel"><H3 class="ms-standardheader"><nobr>Status<span class="ms-formvalidation"> *</span></nobr></H3></td>
<td width="400px" valign="top" class="ms-formbody"><span dir="none"><select name="ctl00$m$g_193d5406_ba72_454b_b14c_87873ba714d6$ff6_1$ctl00$DropDownChoice" id="ctl00_m_g_193d5406_ba72_454b_b14c_87873ba714d6_ff6_1_ctl00_DropDownChoice" title="Status" class="ms-RadioText">
<option selected="selected" value="Not Yet Reconciled">Not Yet Reconciled</option>
<option value="Reconciled">Reconciled</option>
<option value="Reviewed">Reviewed</option>
<option value="Rejected by Reviewer">Rejected by Reviewer</option>
<option value="Approved">Approved</option>
<option value="Rejected by Approver">Rejected by Approver</option>
</select><br></span></td></tr>
===========================================================
Annoying wrapper displayed:
<tr><td width="190px" valign="top" class="ms-formlabel"><H3 class="ms-standardheader"><nobr>Profit Centre<span class="ms-formvalidation"> *</span></nobr></H3></td>
<td width="400px" valign="top" class="ms-formbody">
<div align="left" class="ms-formfieldcontainer">
<div class="ms-formfieldlabelcontainer" nowrap="nowrap">
<span class="ms-formfieldlabel" nowrap="nowrap">Profit Centre</span></div>
<div class="ms-formfieldvaluecontainer">
<span dir="none">
<input name="ctl00$m$g_7716bb24_9fc9_4e72_a2c6_bec888418014$ff6_1$ctl00$ctl00$TextField" type="text" value="ALL" maxlength="255" id="ctl00_m_g_7716bb24_9fc9_4e72_a2c6_bec888418014_ff6_1_ctl00_ctl00_TextField" title="Profit Centre" class="ms-long" /><br>
</span></div></div></td></tr>
<tr><td width="190px" valign="top" class="ms-formlabel"><H3 class="ms-standardheader"><nobr>Status<span class="ms-formvalidation"> *</span></nobr></H3></td>
<td width="400px" valign="top" class="ms-formbody">
<div align="left" class="ms-formfieldcontainer">
<div class="ms-formfieldlabelcontainer" nowrap="nowrap">
<span class="ms-formfieldlabel" nowrap="nowrap">Status</span></div><div class="ms-formfieldvaluecontainer">
<span dir="none">
<select name="ctl00$m$g_7716bb24_9fc9_4e72_a2c6_bec888418014$ff7_1$ctl00$DropDownChoice" id="ctl00_m_g_7716bb24_9fc9_4e72_a2c6_bec888418014_ff7_1_ctl00_DropDownChoice" title="Status" class="ms-RadioText">
<option value="Not Yet Reconciled">Not Yet Reconciled</option>
<option selected="selected" value="Reconciled">Reconciled</option>
<option value="Reviewed">Reviewed</option>
<option value="Rejected by Reviewer">Rejected by Reviewer</option>
<option value="Approved">Approved</option>
<option value="Rejected by Approver">Rejected by Approver</option>
</select><br></span></div></div></td></tr>
How do I remove the extra field containers and related field labels? Why did it behave differently on these two SP2007 environments?
Your tips and answers are much appreciated. Thanks in advance.
It turns out the two environment were of different flavours. The TST environment was running SharePoint Content Management Server with Microsoft.SharePoint.dll version = 12.0.6421.1000. While as the PRD environment was an Enterprise edtion with Microsoft.SharePoint.dll version = 12.0.6565.5001.
And thanks Mirjam for this excellent solution:
http://social.msdn.microsoft.com/Forums/en-CA/sharepointcustomization/thread/f00d37d3-2254-44fa-8f4d-ae7683c645cf
The workaround is to inject a piece of CSS style sheet to override these two OOB classes:
<style type="text/css">
.ms-formfieldlabelcontainer {
display: none;
}
.ms-formfieldvaluecontainer {
border: 0px;
border-style:hidden;
padding:0px;
margin:0px;
}
</style>
And everything looks great now!

Number of Search Results from Excel

Given a column of strings I would like to find the number of search results from a website (e.g. sciencedirect.com) for each string. An existing answer Number of Google Results from Excel works well for Google.
Unfortunately this solution creates the search URL from the string i.e. a Google search for example contains the word example. The sites I want to use do not do this.
A search for example returns the URL http://www.sciencedirect.com/science?_ob=ArticleListURL&_method=list&_ArticleListID=1860967815&_sort=r&_st=13&view=c&_acct=C000053194&_version=1&_urlVersion=0&_userid=1495569&md5=0ef30742e917da15236ef1824058a1db&searchtype=a
Any idea how I achived the same result with this type of search engine.
You'll have to examine the form you submit when you click on the Search button. The form sends a GET request which containes the search terms, but then you get redirected to the result list page, and the URL of the results page does not contain the search terms any more.
I have successfully searched for "corpus" with this URL:
http://www.sciencedirect.com/science?_ob=QuickSearchURL&_method=submitForm&_acct=C000228598&_origin=home&_zone=qSearch&md5=61ce8901b141d527683913a240486ac4&qs_all=corpus
Note that what you'll have to do is
download the start page http://www.sciencedirect.com/
extract hidden fields from the search form
assemble the search URL from the hidden fields
add your search term to the search URL in the qs_all field
send GET request with the search URL
follow redirection
Except for qs_all all other fields in this URL comes from the the form as hidden fields.
This is the source of the corresponding form, as I downloaded it (before sending the "corpus" search request.):
<form name="qkSrch" method="get" target="_top" action="/science" style="margin:0px;">
<input type="hidden" name="_ob" value="QuickSearchURL">
<input type="hidden" name="_method" value="submitForm">
<input type="hidden" name="_acct" value="C000228598">
<input type="hidden" name="_origin" value="home">
<input type="hidden" name="_zone" value="qSearch">
<input type="hidden" name="md5" value="61ce8901b141d527683913a240486ac4">
<table border="0" width="100%" cellpadding="0" cellspacing="0" style="margin: 0;">
<tbody><tr valign="middle">
<!-- Code related for toggling labels -->
<td align="right"><label for="qs_all" id="fieldLabel"> All fields</label></td>
<td align="left"><input class="textbox qsinput xpstyle" type="text" name="qs_all" id="qs_all" value="" size="30" maxlength="450" title="For example: heart attack AND behavior?" tabindex="1"></td>
<td align="right"><label for="qs_author"> Author</label></td>
<td align="left" colspan="5"><input class="textbox qsinput xpstyle" type="text" name="qs_author" id="qs_author" value="" size="33" maxlength="450" title="e.g. J S Smith or John Smith or Smith JS" tabindex="2" style="_width:100%"></td>
<td nowrap="nowrap">
</td><td></td><td></td>
<td align="right" nowrap="nowrap" width="90%" valign="middle">
Advanced search
</td>
</tr>
<tr>
<td align="right"><label for="qs_title"> Journal/Book title</label></td>
<td align="left"><input class="textbox qsinput xpstyle" type="text" id="qs_title" name="qs_title" value="" size="30" maxlength="450" title="For example: journal of molecular biology" tabindex="3"></td>
<td align="right" class="toggleQukSrch2"><label for="qs_vol" id="volField"> Volume</label></td>
<td align="left" class="toggleQukSrch"><input class="textbox qsinput xpstyle" type="text" name="qs_vol" id="qs_vol" value="" size="3" maxlength="10" style="width:30px;" tabindex="4"></td>
<td align="right" class="toggleQukSrch2"><label for="qs_issue" id="issueField"> Issue</label></td>
<td align="left" class="toggleQukSrch"><input class="textbox qsinput xpstyle" type="text" name="qs_issue" id="qs_issue" value="" size="3" maxlength="10" style="width:30px" tabindex="5"></td>
<td align="right" class="toggleQukSrch2"><label for="qs_pages" id="pageField"> Page</label></td>
<td align="right" class="toggleQukSrch"><input class="textbox qsinput xpstyle" type="text" name="qs_pages" id="qs_pages" value="" size="3" maxlength="10" title="For example: 14-27" style="width:30px" tabindex="6"></td>
<td align="right" nowrap="nowrap">
<input class="button" id="submit_search" type="Submit" alt="Submit Quick Search" title="Submit Quick Search" value="Search ScienceDirect" tabindex="8" name="sdSearch">
</td>
<td align="right" nowrap="nowrap" colspan="8" valign="bottom">
<a class="icon_qmarkHelpsci_dir" href="/science?_ob=HelpURL&_file=qs_tips.htm&_acct=C000228598&_version=1&_urlVersion=0&_userid=10&md5=2bd779305b31602341744eaa786e2f0a" target="sdhelp" onmouseover="window.status='Help is Available';return true" onmouseout="window.status='';return true" onclick="var helpWin;helpWin=window.open('/science?_ob=HelpURL&_file=qs_tips.htm&_acct=C000228598&_version=1&_urlVersion=0&_userid=10&md5=2bd779305b31602341744eaa786e2f0a','sdhelp','scrollbars=yes,resizable=yes,directories=no,toolbar=no,menubar=no,status=no,width=760,height=570');helpWin.focus();return false" tabindex="9" style="font-size:0.92em;padding-right:0;">Search tips</a>
</td>
</tr>
</tbody></table>
</form>
EDIT
Continued with How to extract the number of results from the results page.
Your assumption is right, you'll have to change other parts of the code, namely that extracts the number of results value.
Let's stick with the previous example.
When searching from "corpus", you will find this line in the source of the result page:
<input type="hidden" name="TOTAL_PAGES" value="2836">
And you'll want to extract 2836. Hence you will search for something like <input type="hidden" name="TOTAL_PAGES" value=" and get the subequent value before the closing quote.
I am not going to tell you how to code in VBA, but it is basic String manipulation so I hope you can handle it.

Resources