Difference between revisions of "Functions:pageSearchGet"
(→Examples) |
|||
(9 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{Page Template Functions Shortcuts}} | ||
== Description == | == Description == | ||
Retrieves page and product data on pages that qualify for a keyword search. | Retrieves page and product data on pages that qualify for a keyword search. | ||
Line 75: | Line 76: | ||
// product fields | // product fields | ||
[productName] => STRING (for first product in page) | [productName] => STRING (for first product in page) | ||
+ | [productNumber] => STRING (for first product in page) | ||
+ | [catalogNumber] => STRING (for first product in page) | ||
[productTitle] => STRING (for first product in page) | [productTitle] => STRING (for first product in page) | ||
[productDescription] => STRING (for first product in page) | [productDescription] => STRING (for first product in page) | ||
Line 87: | Line 90: | ||
[lowestLevelPrice] => DECIMAL | [lowestLevelPrice] => DECIMAL | ||
[lowestAllPrice] => DECIMAL | [lowestAllPrice] => DECIMAL | ||
+ | [isConfigurable] => BIT | ||
+ | [isDiscontinued] => BIT | ||
+ | [addToCartLink] => STRING | ||
//children's children and children's grandchildren (great grandchildren to parent pageId) | //children's children and children's grandchildren (great grandchildren to parent pageId) | ||
Line 106: | Line 112: | ||
{|border=2 | {|border=2 | ||
|- | |- | ||
− | |Element | + | |<b>Element</b> |
− | |Description | + | |<b>Description</b> |
− | |Example | + | |<b>Example</b> |
|- | |- | ||
− | |fields automatically included | + | |<b>fields automatically included</b> |
|- | |- | ||
|relevance | |relevance | ||
Line 143: | Line 149: | ||
|- | |- | ||
|templateId | |templateId | ||
− | | | + | |INT - system assigned unique template id for the template selected in page management for this page |
− | | | + | |12 |
|- | |- | ||
|notice | |notice | ||
− | | | + | |STRING - notice field entry for this page in page management. Note that notice has to be turned on in Settings to be available in page management. Also notice can be renamed in Settings, therefore might not be titled 'notice' in page management. Often notice is used as the Page Name (unique description of the page for internal use / page identification) |
− | | | + | |This is my page |
|- | |- | ||
|title | |title | ||
− | | | + | |STRING - title field entry for this page in page management. Note that title can be renamed in Settings, therefore might not be titled 'title' in page management. This is used as the text descriptor of the page in all areas of administration that list pages (page children, parents, page search, etc). Other fields may be designated to appear as descriptors in administration by changing the Summary Listing Details under the Page Management tab. |
− | | | + | |The page title |
|- | |- | ||
|subTitle | |subTitle | ||
− | | | + | |STRING - subtitle field entry for this page in page management. Note that subtitle has to be turned on in Settings to be available in page management. Also subtitle can be renamed in Settings, therefore might not be titled 'subtitle' in page management. |
− | | | + | |This is the subtitle for this page |
|- | |- | ||
|copy | |copy | ||
− | | | + | |STRING - HTML formatted page copy, as set in the copy field WYSIWYG editor in page management. This serves as the bulk of the page's content. Copy is typically not displayed in page searches / page children as it is to much information when listing multiple page results, though sometimes it is truncates in the results. Note that copy is HTML content, as it is managed by the WYSIWYG editor. |
− | | | + | |<img src="image.jpg" align="right"><p>This is the <b>copy>/b> for this <i>page</i> |
|- | |- | ||
|summary | |summary | ||
− | | | + | |STRING - summary information about the page. Typically used to describe the page in brief, such as in children, search results and cross sells. |
− | | | + | |This is some additional details about this page. To see more information click this page. |
|- | |- | ||
|summaryImage | |summaryImage | ||
− | | | + | |STRING - absolute path to an image used in summaries about the page. Typically used to accompany the summary when describing the page in brief, such as in children, search results and cross sells. |
− | | | + | |/files/images/thumbnails/imageName.jpg |
|- | |- | ||
|summaryImageAlt | |summaryImageAlt | ||
− | | | + | |STRING - alt tag contents for the summaryImage. |
− | | | + | |This describes the image |
|- | |- | ||
|summaryImageCaption | |summaryImageCaption | ||
− | | | + | |STRING - caption to accompany the summaryImage. |
− | | | + | |The above is an image! |
|- | |- | ||
|linkText | |linkText | ||
− | | | + | |STRING - text to represent the link to go to the page. |
− | | | + | |Click here for more information |
|- | |- | ||
|publisher | |publisher | ||
− | | | + | |STRING - name of the publisher of the page. Typically used when the page is an article, press release or content that is owned by another party. Only available in Page Management if publishing information is set to available in Settings. |
− | | | + | |New York Times |
|- | |- | ||
|publishDate | |publishDate | ||
− | | | + | |DATETIME - date to present as the publishing date of the page. Typically used when the page is an article or press release. Only available in Page Management if publishing information is set to available in Settings. |
− | | | + | |2008-10-16 08:00:00 |
|- | |- | ||
− | |startDate | + | |startDate |
− | | | + | |DATETIME - designates the first day the page should be made available to visitors. If empty, than there is no cut off start date. |
− | | | + | |2008-10-01 00:00:00 |
|- | |- | ||
|endDate | |endDate | ||
− | | | + | |DATETIME - designates the last day the page should be available to visitors. If empty, than there is no cut off end date. |
− | | | + | |2008-10-31 00:00:00 |
|- | |- | ||
|isBlog | |isBlog | ||
− | | | + | |BIT - 0 or 1 if page is selected to be a blog (controlled in page management, but set on automatically when a blog is created by a site visitor). Use to create logic that shows / processes blog related content and logic. Note that this option will only be available in page management if Blogging Available is selected in Settings. |
− | | | + | |1 |
|- | |- | ||
|isPoll | |isPoll | ||
− | | | + | |BIT - 0 or 1 if page is selected to be a poll via page management. Use to create logic that shows / processes poll related content and logic. Note that this option will only be available in page management if Polling Available is selected in Settings. |
− | | | + | |0 |
|- | |- | ||
|createDate | |createDate | ||
− | | | + | |DATETIME - system generated datetime when the page record was first inserted into the database. |
− | | | + | |2008-10-15 14:15:56 |
|- | |- | ||
|modDate | |modDate | ||
− | | | + | |DATETIME - system generated datetime when the page was last modified. |
− | | | + | |2008-10-15 16:12:44 |
|- | |- | ||
− | |author fields | + | |<b>author fields</b> |
|- | |- | ||
|author_firstName | |author_firstName | ||
− | | | + | |STRING - first name of the user designated as the author of the page. This is the first name assigned to the user record for the user with the userId matching the authorId selected in page management for this page. Authors may only be selected if User Publisher Information is selected in Settings. |
− | | | + | |Mark |
|- | |- | ||
|author_lastName | |author_lastName | ||
− | | | + | |STRING - last name of the user designated as the author of the page. This is the last name assigned to the user record for the user with the userId matching the authorId selected in page management for this page. Authors may only be selected if User Publisher Information is selected in Settings. |
− | | | + | |Wexler |
|- | |- | ||
|author_userImage | |author_userImage | ||
− | | | + | |STRING - path to image selected for as the user image for the user designated as the author for the page. Authors may only be selected if User Publisher Information is selected in Settings. |
− | | | + | |/files/images/imagename.jpg |
|- | |- | ||
|author_handle | |author_handle | ||
− | | | + | |STRING - Handle of the user designated as the author of the page. This is the handle assigned to the user record for the user with the userId matching the authorId selected in page management for this page. Authors may only be selected if User Publisher Information is selected in Settings. |
− | | | + | |mwex501 |
|- | |- | ||
− | |blogger fields | + | |<b>blogger fields</b> |
|- | |- | ||
|blog_firstName | |blog_firstName | ||
− | | | + | |STRING - First name of the user designated as the blog owner of the page. This is the first name assigned to the user record for the user with the userId matching the blog_userId selected in page management for this page. Bloggers may only be selected if Blogging Available is selected in Settings. |
− | | | + | |Mark |
|- | |- | ||
|blog_lastName | |blog_lastName | ||
− | | | + | |STRING - Last name of the user designated as the blog owner of the page. This is the last name assigned to the user record for the user with the userId matching the blog_userId selected in page management for this page. Bloggers may only be selected if Blogging Available is selected in Settings. |
− | | | + | |Wexler |
|- | |- | ||
|blog_userImage | |blog_userImage | ||
− | | | + | |STRING - Path of the user image of the user designated as the blog owner of the page. This is the user image path assigned to the user record for the user with the userId matching the blog_userId selected in page management for this page. Bloggers may only be selected if Blogging Available is selected in Settings. |
− | | | + | |/files/images/image.jpg |
|- | |- | ||
|blog_handle | |blog_handle | ||
− | | | + | |STRING -Handle of the user designated as the blog owner of the page. This is the handle assigned to the user record for the user with the userId matching the blog_userId selected in page management for this page. Bloggers may only be selected if Blogging Available is selected in Settings. |
− | | | + | |mwex501 |
|- | |- | ||
− | |forum / comments fields | + | |<b>forum / comments fields</b> |
|- | |- | ||
|forumCount | |forumCount | ||
− | | | + | |INT - number of forum posts to the page. |
− | | | + | |23 |
|- | |- | ||
|ratingTotal | |ratingTotal | ||
− | | | + | |INT - Sum of all ratings posted to this page (each rating is on a scale of 0 to 5). |
− | | | + | |120 |
|- | |- | ||
|ratingCount | |ratingCount | ||
− | | | + | |INT - total number of ratings submitted for the page. |
− | | | + | |50 |
|- | |- | ||
|ratingAverage | |ratingAverage | ||
− | | | + | |FLOAT - average rating for the page on a scale of 0 to 5. |
− | | | + | |2.4 |
|- | |- | ||
− | |product fields | + | |<b>product fields</b> |
|- | |- | ||
|productName | |productName | ||
− | | | + | |STRING - The name of the first product directly assigned to the page in relationships. |
− | | | + | |Product X |
+ | |- | ||
+ | |productNumber | ||
+ | |STRING - The product number of the first product directly assigned to the page in relationships. | ||
+ | |1234XYZ | ||
+ | |- | ||
+ | |catalogNumber | ||
+ | |STRING - The catalog number of the first product directly assigned to the page in relationships. | ||
+ | |234ABC | ||
|- | |- | ||
|productTitle | |productTitle | ||
− | | | + | |STRING - The title of the first product directly assigned to the page in relationships. |
− | | | + | |This is the title of this product |
|- | |- | ||
|productDescription | |productDescription | ||
− | | | + | |STRING - the description of the first product directly assigned to the page in relationships. |
− | | | + | |This is a description of the product |
|- | |- | ||
|productId | |productId | ||
− | | | + | |INT - unique id assigned by the system to the product upon creation, for the first product assigned to the page in relationships |
− | | | + | |12 |
|- | |- | ||
|lowestPrice | |lowestPrice | ||
− | | | + | |FLOAT - lowest price for All products assigned to the page in relationships. This price only takes into consideration the 'price' field for the products, not the sale, level prices. |
− | | | + | |12.59 |
|- | |- | ||
|lowestListPrice | |lowestListPrice | ||
− | | | + | |FLOAT - lowest of all the list prices for ALl products assigned to the page in relationships. |
− | | | + | |15.46 |
|- | |- | ||
|lowestSalePrice | |lowestSalePrice | ||
− | | | + | |FLOAT - lowest of all the available sale prices for all products assigned to the page in relationships. Sale prices that are not within the sale from / to price range do not qualify. |
− | | | + | |14.26 |
|- | |- | ||
|productCount | |productCount | ||
− | | | + | |INT - number of products assigned to the page in relationships. |
− | | | + | |3 |
|- | |- | ||
|productIdList | |productIdList | ||
− | | | + | |STRING - comma delimited list of unique productIds for products assigned to the page in relationships. |
− | | | + | |14,26,3 |
|- | |- | ||
|saleFromDate | |saleFromDate | ||
− | | | + | |DATETIME - date when the sale price is first available for the first product assigned to the page in relationships. If no sale from date is assigned the value will be empty, meaning there is no beginning cut off date for the sale. |
− | | | + | |2008-10-12 00:00:00 |
|- | |- | ||
|saleToDate | |saleToDate | ||
− | | | + | |DATETIME - date when the sale price is last available for the first product assigned to the page in relationships. If no sale to date is assigned the value will be empty, meaning there is no ending cut off date for the sale. |
− | | | + | |2008-10-20 00:00:00 |
|- | |- | ||
|lowestLevelPrice | |lowestLevelPrice | ||
− | | | + | |FLOAT - lowest of all the level prices for all products assigned to the page in relationships. |
− | | | + | |10.26 |
|- | |- | ||
|lowestAllPrice | |lowestAllPrice | ||
− | | | + | |FLOAT - lowest price for All products assigned to the page in relationships. This price takes into consideration sale, regular, list and level (tiered) pricing. Sale prices that are not within the sale from / to price range do not qualify. |
− | | | + | |14.22 |
|- | |- | ||
− | | | + | |isConfigurable |
+ | |BIT - 1 if product is configurable (has options or can be personalized), 0 if not | ||
+ | |0 | ||
+ | |- | ||
+ | |isDiscontinued | ||
+ | |BIT - 1 of product is discontinued. 0 if not | ||
+ | |1 | ||
+ | |- | ||
+ | |addToCartLink | ||
+ | |STRING - use this link for an 'add to cart' button for this child. The string will add the item to the cart IF the child has only one product AND the product has no options AND the product is not discontinued AND the product is not personalizable. Otherwise this string will link to the child page. | ||
+ | |index.php?fa=ORDER.cartAdd&productId=123&quantity=1 | ||
+ | |- | ||
+ | |<b>qualifying pages' children and grandchildren</b> | ||
|- | |- | ||
|childPageCount | |childPageCount | ||
− | | | + | |INT - total count of pages set as children to this page via relationships. |
− | | | + | |6 |
|- | |- | ||
|grandChildPageCount | |grandChildPageCount | ||
− | | | + | |INT - total count of all pages set as grandchildren (children to children) to this page via relationships. Warning, with sites containing many pages / relationships, using this field could cause undue strain on the system. |
− | | | + | |143 |
|- | |- | ||
− | |poll data | + | |<b>poll data</b> |
|- | |- | ||
|pollCount | |pollCount | ||
− | | | + | |INT - total number of poll postings to this page |
− | | | + | |123 |
|- | |- | ||
− | |custom fields | + | |<b>custom fields</b> |
|- | |- | ||
|custom_field_? | |custom_field_? | ||
− | | | + | |Each custom field will be accessible by using custom_field_? where the ? is the field name as set in page template administration for the template used by the page. |
− | | | + | |-anything- |
|} | |} | ||
== Examples == | == Examples == | ||
− | ;Example | + | ;Simple Example |
<source lang="php"> | <source lang="php"> | ||
// call | // call | ||
Line 360: | Line 386: | ||
echo "<br><i>Relevance:" . $search['relevance'] . "</i>"; | echo "<br><i>Relevance:" . $search['relevance'] . "</i>"; | ||
}; | }; | ||
+ | </source> | ||
+ | ;Complex Example using pagination, sorting controls | ||
+ | <source lang="php"> | ||
+ | // make sure our keywords attribute is passed | ||
+ | if(!isset($attributes['keywords'])) $attributes['keywords'] = ''; | ||
+ | |||
+ | // default sorting commands | ||
+ | if(!isset($attributes['orderBy'])) $attributes['orderBy'] = 'relevance'; | ||
+ | if(!isset($attributes['orderType'])) $attributes['orderType'] = 'num'; | ||
+ | if(!isset($attributes['orderDir'])) $attributes['orderDir'] = 'DESC'; | ||
+ | |||
+ | // get the sorting results | ||
+ | $arrChildren = eV::pageSearchGet($attributes['keywords'],"pageId,link,templateId,summaryImage,title,summary,lowestAllPrice,productId,productCount,addToCartLink,relevance",$attributes['orderBy'],$attributes['orderDir'],$attributes['orderType']); | ||
+ | |||
+ | // go to no items found page if empty | ||
+ | // substitute '#' with the pageId to go to | ||
+ | if(count($arrChildren) == 0) eV::redirect("index.php?pageId=#&keywords=" . urlencode($attributes['keywords'])); | ||
+ | |||
+ | // if only 1 result found, lets just forward to that page | ||
+ | if(count($arrChildren) == 1) eV::redirect('/index.php?pageId=' . $arrChildren[0]['pageId']); | ||
+ | |||
+ | // preset control attributes | ||
+ | // view all attribute specifies if we are to page or show everything that qualifies | ||
+ | if(!isset($attributes['viewAll'])) $attributes['viewAll'] = 0; | ||
+ | // pageNo states the current page number in pagination that we are on | ||
+ | if(!isset($attributes['pageNo'])) $attributes['pageNo'] = 0; | ||
+ | // perPage sets the number of items to show in a page | ||
+ | if(!isset($attributes['perPage'])) $attributes['perPage'] = 6; | ||
+ | // if view all is on, lets show all items on this page | ||
+ | if($attributes['viewAll']) $attributes['perPage'] = count($arrChildren); | ||
+ | |||
+ | // call pagination | ||
+ | // functions returns an array that contains the pagination links, start and end child index | ||
+ | // be sure to include your order (sort) attributes and keyword attribute | ||
+ | $pagination = eV::pagination(count($arrChildren),$attributes['perPage'],$attributes['pageNo'],"index.php?pageId=$pageId&keywords=" . urlencode($attributes['keywords']). "&orderBy=" . $attributes['orderBy'] . "&orderType=" . $attributes['orderType'] . "&orderDir=" . $attributes['orderDir']); | ||
+ | |||
+ | // spit out some page content | ||
+ | echo "<h2>Your search for \"" . $attributes['keywords'] . "\" was successful!</h2> | ||
+ | <p>" . $copy . "</p> | ||
+ | "; | ||
+ | |||
+ | // form to run another search | ||
+ | // use get method so keyword searches are cachable, trackable by 3rd party tools | ||
+ | echo " | ||
+ | <form action=\"index.php\" method=\"get\"> | ||
+ | <hr> | ||
+ | Would you like to search again? | ||
+ | <br>Enter Keyword or Item Number: | ||
+ | <input name=\"keywords\" type=\"text\" value=\"\" /> | ||
+ | <input type=\"hidden\" name=\"pageId\" value=\"" . $pageId . "\"> | ||
+ | <input type=\"submit\" value\"GO!\"> | ||
+ | </form> | ||
+ | "; | ||
+ | |||
+ | // output pagination header | ||
+ | echo " | ||
+ | <hr> | ||
+ | (Showing " . ($pagination['startIndex']+1) . "-" . ($pagination['endIndex']+1) . " of " . count($arrChildren) . ")"; | ||
+ | |||
+ | // form to sort results | ||
+ | // you can sort by any field you request in the eV::pageSearchGet function | ||
+ | // be sure to include your keyword attributes, pageId, view all status | ||
+ | echo " | ||
+ | <br>Sort: | ||
+ | <form name=\"sortForm\"> | ||
+ | <select name=\"sortSelect\" size=\"1\" onchange=\"window.location.href=document.sortForm.sortSelect.options[document.sortForm.sortSelect.selectedIndex].value;\"> | ||
+ | <option value=\"#\" selected=\"selected\">Sort by</option> | ||
+ | <option value=\"index.php?pageId=$pageId&viewAll=" .$attributes['viewAll'] . "&orderBy=relevance&orderType=num&orderDir=DESC&keywords=" . urlencode($attributes['keywords']) . "\">Relevance</option> | ||
+ | <option value=\"index.php?pageId=$pageId&viewAll=" .$attributes['viewAll'] . "&orderBy=lowestAllPrice&orderDir=ASC&orderType=num&orderDir=ASC&keywords=" . urlencode($attributes['keywords']) . "\">Price</option> | ||
+ | <option value=\"index.php?pageId=$pageId&viewAll=" .$attributes['viewAll'] . "&orderBy=createDate&orderDir=DESC&orderType=num&keywords=" . urlencode($attributes['keywords']) . "\">Newest</option> | ||
+ | <option value=\"index.php?pageId=$pageId&viewAll=" .$attributes['viewAll'] . "&orderBy=title&orderDir=ASC&orderType=str&orderDir=ASC&keywords=" . urlencode($attributes['keywords']) . "\">Alphabetical</option> | ||
+ | </select> | ||
+ | </form> | ||
+ | "; | ||
+ | |||
+ | // pagination page links | ||
+ | echo "<hr>Pages: " . $pagination['links']; | ||
+ | |||
+ | // view all link | ||
+ | // only show if we are not viewing all | ||
+ | if (!$attributes['viewAll']) echo "<br><a href=\"index.php?pageId=$pageId&keywords=" . urlencode($attributes['keywords']) . "&orderBy=" . $attributes['orderBy'] . "&orderDir=" . $attributes['orderDir']. "&orderType=" . $attributes['orderType'] . "&viewAll=1\">(VIEW ALL)</a> "; | ||
+ | |||
+ | // now lets show the items returned | ||
+ | // set tracker to note which child we are on | ||
+ | $childIndex = 0; | ||
+ | |||
+ | // loop thru children | ||
+ | foreach($arrChildren as $child){ | ||
+ | // only show children that are within the start and end index as returned by eV::pagination function | ||
+ | if($pagination['startIndex'] <= $childIndex && $pagination['endIndex'] >= $childIndex){ | ||
+ | // display the child | ||
+ | echo "<hr><a href=\"" . $child['link'] . "\"><img src=\"" . $child['summaryImage'] . "\"/></a> | ||
+ | <br><a href=\"" . $child['link'] . "\">" . $child['title'] . "</a> | ||
+ | <br>" . $child['summary'] . " | ||
+ | <br>As low as " . eV::dollarFormat($child['lowestAllPrice']) . " each! | ||
+ | <br><a href=\"" . $child['link'] . "\">More Info</a> | ||
+ | <br><a href=\"" . $child['addToCartLink']. "\">Add To Cart</a>"; | ||
+ | } | ||
+ | // increment tracking index | ||
+ | $childIndex++; | ||
+ | } | ||
+ | |||
</source> | </source> |
Latest revision as of 15:29, 8 April 2009
Description
Retrieves page and product data on pages that qualify for a keyword search.
Syntax
$arrPages= eV::pageSearchGet($keywords[,$fieldList=NULL][,$orderBy=NULL][,$orderDir="DESC"][,$orderType="str"]);
Paramaters
- $keywords STRING
- Keywords to be used to qualify the page search
- $fieldList STRING (optional)
- comma delimited list of field names you would like returned. leaving this value empty will return all fields, though this is not recommended as it could significantly reduce system performance. Page custom fields can be requested by prepending the custom field name with "custom_field_" (example: to include the "myVar" custom field, add "custom_field_myVar" to the $fieldList).
- $orderBy STRING (optional)
- field to order by. This field must be present in the $fieldList. defaults to 'orderId' which corresponds to the order the children are listed in relationships management for the parent $pageId
- $orderDir STRING (optional)
- Either "ASC" or "DESC" signifying the direction of the sorted results. Defaults to "DESC".
- $orderType STRING (optional)
- Either "str" or "num" signifying how the values will be compared when sorting the results. Defaults to "str"
Return Values
Returns a multidimensional array of page data that qualifies for the search. The first dimension is a numerically indexed array of each child (starting from 0). The second dimension is an associative array of keys corresponding to the fields requested in the $fieldList attribute (if $fieldList is empty, all fields are returned. This is not recommended as it creates unnecessary overhead).
The returned array is as follows (all possible fields are listed, note that only fields requested will be returned):
Array ( [0] => Array ( // fields automatically included [relevance] => FLOAT [pageId] => INT [blog_userId] => INT // user id for blogger [authorId] => INT // user id for author [isLinkDirect] => BIT // signal that this is an outside link circumvents page forwarding [isForum] => BIT [link] => STR //page data [templateId] => INT [notice] => STR [title] => STR [subTitle] => STR [copy] => STR [summary] => STR [summaryImage] => STR [summaryImageAlt] => STR [summaryImageCaption] => STR [linkText] => STR [publisher] => STR [publishDate] => DATETIME [startDate] => DATETIME [endDate] => DATETIME [isBlog] => BIT [isPoll] => BIT [createDate] => DATETIME [modDate] => DATETIME // author fields [author_firstName] => STRING [author_lastName] => STRING [author_userImage] => STRING [author_handle] => STRING // blogger fields [blog_firstName] => STRING [blog_lastName] => STRING [blog_userImage] => STRING [blog_handle] => STRING // forum / comments fields [forumCount] => INT [ratingTotal] => INT [ratingCount] => INT [ratingAverage] => DECIMAL // product fields [productName] => STRING (for first product in page) [productNumber] => STRING (for first product in page) [catalogNumber] => STRING (for first product in page) [productTitle] => STRING (for first product in page) [productDescription] => STRING (for first product in page) [productId] => INT (for first product in page) [lowestPrice] => DECIMAL [lowestListPrice] => DECIMAL [lowestSalePrice] => DECIMAL [productCount] => INT [productIdList] => STRING (comma delimited list of INT) [saleFromDate] => DATETIME (for first product in page) [saleToDate] => DATETIME (for first product in page) [lowestLevelPrice] => DECIMAL [lowestAllPrice] => DECIMAL [isConfigurable] => BIT [isDiscontinued] => BIT [addToCartLink] => STRING //children's children and children's grandchildren (great grandchildren to parent pageId) [childPageCount] => INT [grandChildPageCount] => INT //poll data [pollCount] => INT //custom fields [custom_field_?] => ? ) [1] => Array ... )
Elements from the page associative array are as follows:
Element | Description | Example |
fields automatically included | ||
relevance | FLOAT - a numerical representation of how relevant the page is to the keywords entered. Higher number = more relevant. | 1.12 |
pageId | INT - system assigned unique pageId of the returned page | 6 |
blog_userId | INT - system assigned unique userId of the blogger designed in page management to this page. If the page is not a blog, value will be empty. | 10 |
authorId | INT - system assigned unique userId of the author designated in page management to this page. If no author is assigned, this value will be empty | 14 |
isLinkDirect | BIT - either 1 or 0 designating if the link is direct. If it is a direct link, the value of the 'link' field will be the ultimate target of the link, regardless if it is internal or external. If the link is not direct, the value of the 'link' field will always be internal - external links will be redirected from the internal page. The latter is for tracking purposes. | 0 |
isForum | BIT - either 1 or 0 designating if the page is selected in page management to be a forum. Note this option will only be available if Forums Available is set on in Settings. Use this flag to hide/show forum related page content and logic, so this data is not displayed / processed if the page manager has forums turned off for the page. | 1 |
link | STRING - the link to this page. This should be placed in the HREF attribute of the A link tag. The system will automatically generate the correct link to the internal / external target and take into consideration if the link is direct (isLinkDirect) or not. | index.php?pageId=192 |
page data | ||
templateId | INT - system assigned unique template id for the template selected in page management for this page | 12 |
notice | STRING - notice field entry for this page in page management. Note that notice has to be turned on in Settings to be available in page management. Also notice can be renamed in Settings, therefore might not be titled 'notice' in page management. Often notice is used as the Page Name (unique description of the page for internal use / page identification) | This is my page |
title | STRING - title field entry for this page in page management. Note that title can be renamed in Settings, therefore might not be titled 'title' in page management. This is used as the text descriptor of the page in all areas of administration that list pages (page children, parents, page search, etc). Other fields may be designated to appear as descriptors in administration by changing the Summary Listing Details under the Page Management tab. | The page title |
subTitle | STRING - subtitle field entry for this page in page management. Note that subtitle has to be turned on in Settings to be available in page management. Also subtitle can be renamed in Settings, therefore might not be titled 'subtitle' in page management. | This is the subtitle for this page |
copy | STRING - HTML formatted page copy, as set in the copy field WYSIWYG editor in page management. This serves as the bulk of the page's content. Copy is typically not displayed in page searches / page children as it is to much information when listing multiple page results, though sometimes it is truncates in the results. Note that copy is HTML content, as it is managed by the WYSIWYG editor. | <img src="image.jpg" align="right"><p>This is the <b>copy>/b> for this <i>page</i> |
summary | STRING - summary information about the page. Typically used to describe the page in brief, such as in children, search results and cross sells. | This is some additional details about this page. To see more information click this page. |
summaryImage | STRING - absolute path to an image used in summaries about the page. Typically used to accompany the summary when describing the page in brief, such as in children, search results and cross sells. | /files/images/thumbnails/imageName.jpg |
summaryImageAlt | STRING - alt tag contents for the summaryImage. | This describes the image |
summaryImageCaption | STRING - caption to accompany the summaryImage. | The above is an image! |
linkText | STRING - text to represent the link to go to the page. | Click here for more information |
publisher | STRING - name of the publisher of the page. Typically used when the page is an article, press release or content that is owned by another party. Only available in Page Management if publishing information is set to available in Settings. | New York Times |
publishDate | DATETIME - date to present as the publishing date of the page. Typically used when the page is an article or press release. Only available in Page Management if publishing information is set to available in Settings. | 2008-10-16 08:00:00 |
startDate | DATETIME - designates the first day the page should be made available to visitors. If empty, than there is no cut off start date. | 2008-10-01 00:00:00 |
endDate | DATETIME - designates the last day the page should be available to visitors. If empty, than there is no cut off end date. | 2008-10-31 00:00:00 |
isBlog | BIT - 0 or 1 if page is selected to be a blog (controlled in page management, but set on automatically when a blog is created by a site visitor). Use to create logic that shows / processes blog related content and logic. Note that this option will only be available in page management if Blogging Available is selected in Settings. | 1 |
isPoll | BIT - 0 or 1 if page is selected to be a poll via page management. Use to create logic that shows / processes poll related content and logic. Note that this option will only be available in page management if Polling Available is selected in Settings. | 0 |
createDate | DATETIME - system generated datetime when the page record was first inserted into the database. | 2008-10-15 14:15:56 |
modDate | DATETIME - system generated datetime when the page was last modified. | 2008-10-15 16:12:44 |
author fields | ||
author_firstName | STRING - first name of the user designated as the author of the page. This is the first name assigned to the user record for the user with the userId matching the authorId selected in page management for this page. Authors may only be selected if User Publisher Information is selected in Settings. | Mark |
author_lastName | STRING - last name of the user designated as the author of the page. This is the last name assigned to the user record for the user with the userId matching the authorId selected in page management for this page. Authors may only be selected if User Publisher Information is selected in Settings. | Wexler |
author_userImage | STRING - path to image selected for as the user image for the user designated as the author for the page. Authors may only be selected if User Publisher Information is selected in Settings. | /files/images/imagename.jpg |
author_handle | STRING - Handle of the user designated as the author of the page. This is the handle assigned to the user record for the user with the userId matching the authorId selected in page management for this page. Authors may only be selected if User Publisher Information is selected in Settings. | mwex501 |
blogger fields | ||
blog_firstName | STRING - First name of the user designated as the blog owner of the page. This is the first name assigned to the user record for the user with the userId matching the blog_userId selected in page management for this page. Bloggers may only be selected if Blogging Available is selected in Settings. | Mark |
blog_lastName | STRING - Last name of the user designated as the blog owner of the page. This is the last name assigned to the user record for the user with the userId matching the blog_userId selected in page management for this page. Bloggers may only be selected if Blogging Available is selected in Settings. | Wexler |
blog_userImage | STRING - Path of the user image of the user designated as the blog owner of the page. This is the user image path assigned to the user record for the user with the userId matching the blog_userId selected in page management for this page. Bloggers may only be selected if Blogging Available is selected in Settings. | /files/images/image.jpg |
blog_handle | STRING -Handle of the user designated as the blog owner of the page. This is the handle assigned to the user record for the user with the userId matching the blog_userId selected in page management for this page. Bloggers may only be selected if Blogging Available is selected in Settings. | mwex501 |
forum / comments fields | ||
forumCount | INT - number of forum posts to the page. | 23 |
ratingTotal | INT - Sum of all ratings posted to this page (each rating is on a scale of 0 to 5). | 120 |
ratingCount | INT - total number of ratings submitted for the page. | 50 |
ratingAverage | FLOAT - average rating for the page on a scale of 0 to 5. | 2.4 |
product fields | ||
productName | STRING - The name of the first product directly assigned to the page in relationships. | Product X |
productNumber | STRING - The product number of the first product directly assigned to the page in relationships. | 1234XYZ |
catalogNumber | STRING - The catalog number of the first product directly assigned to the page in relationships. | 234ABC |
productTitle | STRING - The title of the first product directly assigned to the page in relationships. | This is the title of this product |
productDescription | STRING - the description of the first product directly assigned to the page in relationships. | This is a description of the product |
productId | INT - unique id assigned by the system to the product upon creation, for the first product assigned to the page in relationships | 12 |
lowestPrice | FLOAT - lowest price for All products assigned to the page in relationships. This price only takes into consideration the 'price' field for the products, not the sale, level prices. | 12.59 |
lowestListPrice | FLOAT - lowest of all the list prices for ALl products assigned to the page in relationships. | 15.46 |
lowestSalePrice | FLOAT - lowest of all the available sale prices for all products assigned to the page in relationships. Sale prices that are not within the sale from / to price range do not qualify. | 14.26 |
productCount | INT - number of products assigned to the page in relationships. | 3 |
productIdList | STRING - comma delimited list of unique productIds for products assigned to the page in relationships. | 14,26,3 |
saleFromDate | DATETIME - date when the sale price is first available for the first product assigned to the page in relationships. If no sale from date is assigned the value will be empty, meaning there is no beginning cut off date for the sale. | 2008-10-12 00:00:00 |
saleToDate | DATETIME - date when the sale price is last available for the first product assigned to the page in relationships. If no sale to date is assigned the value will be empty, meaning there is no ending cut off date for the sale. | 2008-10-20 00:00:00 |
lowestLevelPrice | FLOAT - lowest of all the level prices for all products assigned to the page in relationships. | 10.26 |
lowestAllPrice | FLOAT - lowest price for All products assigned to the page in relationships. This price takes into consideration sale, regular, list and level (tiered) pricing. Sale prices that are not within the sale from / to price range do not qualify. | 14.22 |
isConfigurable | BIT - 1 if product is configurable (has options or can be personalized), 0 if not | 0 |
isDiscontinued | BIT - 1 of product is discontinued. 0 if not | 1 |
addToCartLink | STRING - use this link for an 'add to cart' button for this child. The string will add the item to the cart IF the child has only one product AND the product has no options AND the product is not discontinued AND the product is not personalizable. Otherwise this string will link to the child page. | index.php?fa=ORDER.cartAdd&productId=123&quantity=1 |
qualifying pages' children and grandchildren | ||
childPageCount | INT - total count of pages set as children to this page via relationships. | 6 |
grandChildPageCount | INT - total count of all pages set as grandchildren (children to children) to this page via relationships. Warning, with sites containing many pages / relationships, using this field could cause undue strain on the system. | 143 |
poll data | ||
pollCount | INT - total number of poll postings to this page | 123 |
custom fields | ||
custom_field_? | Each custom field will be accessible by using custom_field_? where the ? is the field name as set in page template administration for the template used by the page. |
Examples
- Simple Example
// call $searchArr = eV::pageSearchGet('several keywords here','title,summary,summaryImage,link','relevance','DESC','num'); // output foreach($searchArr as $search) { echo "<hr>"; echo "<a href=\"" . $search['link'] . "\">"; echo "<img align=\"left\" src=\"" . $search['summaryImage'] . "\">"; echo "</a>"; echo "<a href=\"" . $search['link'] . "\">" . $search['title'] . "</a>"; echo "<br>" . $search['summary']; echo "<br><i>Relevance:" . $search['relevance'] . "</i>"; };
- Complex Example using pagination, sorting controls
// make sure our keywords attribute is passed if(!isset($attributes['keywords'])) $attributes['keywords'] = ''; // default sorting commands if(!isset($attributes['orderBy'])) $attributes['orderBy'] = 'relevance'; if(!isset($attributes['orderType'])) $attributes['orderType'] = 'num'; if(!isset($attributes['orderDir'])) $attributes['orderDir'] = 'DESC'; // get the sorting results $arrChildren = eV::pageSearchGet($attributes['keywords'],"pageId,link,templateId,summaryImage,title,summary,lowestAllPrice,productId,productCount,addToCartLink,relevance",$attributes['orderBy'],$attributes['orderDir'],$attributes['orderType']); // go to no items found page if empty // substitute '#' with the pageId to go to if(count($arrChildren) == 0) eV::redirect("index.php?pageId=#&keywords=" . urlencode($attributes['keywords'])); // if only 1 result found, lets just forward to that page if(count($arrChildren) == 1) eV::redirect('/index.php?pageId=' . $arrChildren[0]['pageId']); // preset control attributes // view all attribute specifies if we are to page or show everything that qualifies if(!isset($attributes['viewAll'])) $attributes['viewAll'] = 0; // pageNo states the current page number in pagination that we are on if(!isset($attributes['pageNo'])) $attributes['pageNo'] = 0; // perPage sets the number of items to show in a page if(!isset($attributes['perPage'])) $attributes['perPage'] = 6; // if view all is on, lets show all items on this page if($attributes['viewAll']) $attributes['perPage'] = count($arrChildren); // call pagination // functions returns an array that contains the pagination links, start and end child index // be sure to include your order (sort) attributes and keyword attribute $pagination = eV::pagination(count($arrChildren),$attributes['perPage'],$attributes['pageNo'],"index.php?pageId=$pageId&keywords=" . urlencode($attributes['keywords']). "&orderBy=" . $attributes['orderBy'] . "&orderType=" . $attributes['orderType'] . "&orderDir=" . $attributes['orderDir']); // spit out some page content echo "<h2>Your search for \"" . $attributes['keywords'] . "\" was successful!</h2> <p>" . $copy . "</p> "; // form to run another search // use get method so keyword searches are cachable, trackable by 3rd party tools echo " <form action=\"index.php\" method=\"get\"> <hr> Would you like to search again? <br>Enter Keyword or Item Number: <input name=\"keywords\" type=\"text\" value=\"\" /> <input type=\"hidden\" name=\"pageId\" value=\"" . $pageId . "\"> <input type=\"submit\" value\"GO!\"> </form> "; // output pagination header echo " <hr> (Showing " . ($pagination['startIndex']+1) . "-" . ($pagination['endIndex']+1) . " of " . count($arrChildren) . ")"; // form to sort results // you can sort by any field you request in the eV::pageSearchGet function // be sure to include your keyword attributes, pageId, view all status echo " <br>Sort: <form name=\"sortForm\"> <select name=\"sortSelect\" size=\"1\" onchange=\"window.location.href=document.sortForm.sortSelect.options[document.sortForm.sortSelect.selectedIndex].value;\"> <option value=\"#\" selected=\"selected\">Sort by</option> <option value=\"index.php?pageId=$pageId&viewAll=" .$attributes['viewAll'] . "&orderBy=relevance&orderType=num&orderDir=DESC&keywords=" . urlencode($attributes['keywords']) . "\">Relevance</option> <option value=\"index.php?pageId=$pageId&viewAll=" .$attributes['viewAll'] . "&orderBy=lowestAllPrice&orderDir=ASC&orderType=num&orderDir=ASC&keywords=" . urlencode($attributes['keywords']) . "\">Price</option> <option value=\"index.php?pageId=$pageId&viewAll=" .$attributes['viewAll'] . "&orderBy=createDate&orderDir=DESC&orderType=num&keywords=" . urlencode($attributes['keywords']) . "\">Newest</option> <option value=\"index.php?pageId=$pageId&viewAll=" .$attributes['viewAll'] . "&orderBy=title&orderDir=ASC&orderType=str&orderDir=ASC&keywords=" . urlencode($attributes['keywords']) . "\">Alphabetical</option> </select> </form> "; // pagination page links echo "<hr>Pages: " . $pagination['links']; // view all link // only show if we are not viewing all if (!$attributes['viewAll']) echo "<br><a href=\"index.php?pageId=$pageId&keywords=" . urlencode($attributes['keywords']) . "&orderBy=" . $attributes['orderBy'] . "&orderDir=" . $attributes['orderDir']. "&orderType=" . $attributes['orderType'] . "&viewAll=1\">(VIEW ALL)</a> "; // now lets show the items returned // set tracker to note which child we are on $childIndex = 0; // loop thru children foreach($arrChildren as $child){ // only show children that are within the start and end index as returned by eV::pagination function if($pagination['startIndex'] <= $childIndex && $pagination['endIndex'] >= $childIndex){ // display the child echo "<hr><a href=\"" . $child['link'] . "\"><img src=\"" . $child['summaryImage'] . "\"/></a> <br><a href=\"" . $child['link'] . "\">" . $child['title'] . "</a> <br>" . $child['summary'] . " <br>As low as " . eV::dollarFormat($child['lowestAllPrice']) . " each! <br><a href=\"" . $child['link'] . "\">More Info</a> <br><a href=\"" . $child['addToCartLink']. "\">Add To Cart</a>"; } // increment tracking index $childIndex++; }