I want to start using "lucene" to query "Umbraco" content ,
What is the easiest way to get it up and running.
I tried using easy search "lucene wrapper",
It is working but i am not getting any results from the query,
I try to delete ExamineIndexes from /App_Data/TEMP
But Umbraco do not create new ExamineIndexes file
I am using Umbraco version 7.1.8
And c#
I am trying to query the examineindexes: at the front end
Examine is a Lucene implementation for Umbraco.
Taken from the Umbraco documentation, the following steps should help you get going with searching with Examine and Umbraco:
Create an index
To create a searchable index we need to create 3 things: an Indexer a Searcher and an Index Set.
Open ~/Config/ExamineSettings.config and add an indexer under the 'ExamineIndexProviders/providers' section (in this example it is named ExternalIndexer):
<add name="ExternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"/>
In the same file (~/Config/ExamineSettings.config) add a searcher under the 'ExamineSearchProviders/providers' section (in this example it is named ExternalSearcher):
<add name="ExternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" />
In the same file we'll change the default search provider to the one we've created, set defaultProvider="ExternalSearcher"
Open ~/Config/ExamineIndex.config and add an index set (in this example it is named ExternalIndexSet):
<IndexSet SetName="ExternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/External/" />
We have a searchable index configured using Examine. Examine will detect that the index doesn't exist on the file system yet so the index will be rebuilt during application startup. Once that happens the index will automatically stay up to date with the data in Umbraco.
Searching with Razor
In razor macros there's a Search method on the DynamicNode model which will return a DynamicNodeList:
#if (!string.IsNullOrEmpty(Request.QueryString["query"]))
{
<ul>
#foreach (var result in Umbraco.Search(Request.QueryString["query"]))
{
<li>
#result.Name
</li>
}
</ul>
}
Related
I'm new to a Contao project, and the only dev at the project....
A custom module is created. For this custom module there is a data entry form (defined in a php file in the dca folder), in which a user can enter all the data which is then stored in a custom table.
The code for the module follows the layout stated in the blogpost 'Create a custom module - the basics' (http://blog.qzminski.com/article/create-a-custom-module-the-basics.html).
I've seen a PHP page (in the templates folder) which gets all the data from the custom database table (gets autoinjected via a variable?) and formats that in a html table.
That is what is built so far.
Now what I want to do is to create a display page for an individual item. Normally that will be:
create a link in the existing html table (with the id of the record)
which links to a new page (so for instance
pagenamewhichidonotknow?id=34)
and on that page, receive the id which is sent by the link (get it from the querystring?),
get the data from the custom databasetable (don't know how)
and then create a nice page (do know how to do this ;-))
I realize this is a large question, but I really don't know where to start.
Googling shows me a lot of pages with this warning "This guite was written for Contao 2.x and a lot of it's information is outdated! Read with care and only use as a general-purpose guide." and other pages are in German, which is, despite having learned it for 3 years in highschool, not my usp.
Any help is appreciated.
I hope I get you well. To achieve what you want, you will need to create two frontend modules, listModule and detailsModule and two pages, listPage and detailsPage therefore create these two pages in the backend(site structure). You will add listModule to the listPage and the detailsModule to detailsPage.
Never hardcode the page id unless you have no option.
Lets start on how to link to the detailsPage by creating the listModule and adding it to the listPage
Create /system/modules/my_module/dca/tl_module.php
Add the following code and save
$GLOBALS['TL_DCA']['tl_module']['palettes']['my_module'] = '{title_legend},name,headline,type,linkToDetail;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space';
$GLOBALS['TL_DCA']['tl_module']['fields']['linkToDetail']=array(
'label' => &$GLOBALS['TL_LANG']['tl_module']['linkToDetail'],
'exclude' => true,
'inputType' => 'pageTree',
'foreignKey' => 'tl_page.title',
'eval' => array('fieldType'=>'radio'),
'sql' => "int(10) unsigned NOT NULL default '0'",
'relation' => array('type'=>'hasOne', 'load'=>'eager')
);
This will create a column in your custom table that you will use it later to access the page ID in the template
Run the install tool.
Work on any errors that may arise. If none, go to next
Create the frontend module according to this url Front end module
In the compile function do as below
protected function compile(){
$objItems = $this->Database->execute("SELECT * FROM my_custom_table");
if (!$objItems->numRows)
{
return;
}
$arrItems = array();
// Generate item rows
while ($objItems->next())
{
$objPage = \PageModel::findPublishedById($objItems->linkToDetail);
$arrItems[] = array
(
'linkToDetail' => $objPage->getFrontendUrl('itemId='.$objItems->id),
);
}
$this->Template->items = $arrItems;
}
please note the itemId parameter added to the url
Create a template /system/modules/my_module/templates/my_template.html5
and you will be able to access easily the items
<?php if($this->items): foreach ($this->items as $item): ?>
<div class="item">
<?php if ($item['linkToDetail']): ?>
Please take me to the details page<?php endif; ?>
</div>
<?php endforeach; endif; ?>
Now go to themes -> modules ->new module and create a new module. I am assuming you have followed the instructions in that link on how to add your module to your module list. Assuming you added to the miscellaneous group, select your module. You will see a page picker with label 'linkToDetail'. select the detailsPage you created in the beginning.
Go to articles -> listPage -> new select 'module' as the element type and the choose your listModule above. We are good here. preview your page and you should be good.
Now lets build the detailsModule and add it to the detailsPage
Follow all the steps above only that in the compile function of the details module, you will select the details data as follows``
$objItemDetails = $this->Database->execute("SELECT * FROM my_custom_table where id=".\Input::get('itemId'));
step 7,8 and 9 are same.
This will help in the case where details page changes in times of ID. It makes it dynamic enough.
Hope this helps
To get list of items in the frontend:
Step 1 / create a List-Module:
go to "themes"
click the gears-icon
create a new modul
give it a name
choose the modul-type from the dropdown
(the name of the model to choose should be like this:
"yourCustomModulNameList" or similar)
Step 2 / embed the new List-Module into an Article:
go to articles in the main-menu
edit the article which should contain the list
choose new content-element
choose "Modul" as type
select your named modul
... to create a display page for an individual item, the steps are nearly the same:
create a reader-modul
insert this reader-modul on a new page (in a new article)
tell the previous created list-modul where the reader-modul is
hope this helps :)
Please bear with me because I am very new to Umbraco.
I have a test Umbraco config file that looks like the following:
<Product nodeName="For-test">
<customId>222/</customId>
</Product>
<Product nodeName="For-none">
<customId>333/</customId>
</Product>
In my test.master page, I would only like to match the child element who's parent has the value of "For-test". This should give me the value of "222". I am using the following code to display the element values but I get the following error "Error loading MacroEngine script (file: )" I believe that my syntax is wrong.
<umbraco:Macro runat="server" language="cshtml">
#Model.nodeName="For-test".customId;
</umbraco:Macro>
Which Umbraco version are you using? Version 7 is best when using MVC, so you wouldn't typically have a master page at all.
Also, you shouldn't have to be fiddling with umbraco.config at all.
I would suggest you start by installing the starter kit (maybe in a fresh install?), then you can check out how "it" does things. Also, have a good look in the documentation (https://our.umbraco.org/documentation/) and maybe even check out some of the video tutorials (something like these http://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/templating/).
As for your specific question:
No need to use the <umbraco:Macro /> tag - but since you are in a Web Forms type website (and not MVC), you can't use # to indicate code sections. You'll have to try with <%= %>.
The Umbraco Model is tied to whatever page you are viewing. You can query for content by Id or "nodeTypeAlias" (which in your case would be "Product", and you'd get all Products at once), but not easily by name since it isn't unique.
But I think you can get a much better grasp of how things are done in Umbraco by looking at the links provided above.
For a detailed error go to App_Data/Logs/ and open the newest .txt file.
This is my first time round using Umbraco and I have created Document Types / Pages using the wrong naming format and now this has transpired into my page URL's, for instance /about-page/. How would I go about changing them to /about as I have searched the back-end admin panel and there dose't seem to be an option to change their link to document values.
Would anyone be able to provide a simple code based example using umbracoUrlAlias or umbracoUrlName how I could change this preferably in Razor.
Thanks
Editing #run yards Solution by digbyswift help in comment
Correct Solution:
Create Property on in Document Types which applies to all pages you want to change the URL
Call the name anything you want e.g Page URL and Possibly give it a new tab.
Call the alias umbracoUrlName
Type as text sting
Should not be Mandatory (As when you start replacing .Url with .umbracoUrlAlias within the views it will need to be present)
Tab as Generic
Click Save on top right on the page
Added screenshot for starter kit on Umbraco v7.2.5
Unless I'm very much misunderstanding your issue, you should just be able to change the name of your page and republish. This doesn't need an additional field, just change the value in the "Properties" tab and republish the page. This will automatically change the URL of the page.
You can also create a property called umbracoUrlName using a TextString property editor. If this has a value then it will generate the URL fragment for the page using this value, rather than the page name. This changes the URL for the page, rather than creating an alias, like umbracoUrlAlias.
Solution:
Create property on in Document Types which applies to all pages you want to change the URL
Call the name anything you want e.g Page URL and Possibly give it a new tab.
Call the alias umbracoUrlAlias
Type as text sting
Make it required (As when you start replacing .Url with .umbracoUrlAlias within the views it will need to be present)
Go into all your pages and rename them using the property you just created
Now with your code, say with the navigation where you have used .Url change it to .umbracoUrlAlias and the new URL's will be used.
Note if you don't use .umbracoUrlAlias the links will still be active i.e. they work but they won't be displayed in the address bar as .Url spits out the original ones associated with the page.
You can apply on URL names in web.config:
In section find:
<add key="umbracoUseDirectoryUrls" value="false" />
this will set url names for new created items to name.aspx
If you set this to 'true' then new items will be named like /name/
Additionaly you might want to avoid of Handling some urls by Umbraco pipline, just use this setting - add URLs which must be bypassed:
<add key="umbracoReservedUrls" value="~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd" />
Hello I created some page in Umbraco 4.7 CMS,
configure some alternative links to page(section) it looks like.
If I look at
Link to document
/folder/folder2/page1.aspx - workig
Alternative Links
http://site.com/folder/folder2/page1.aspx - workig
http://site.com/en/folder/folder2/page1.aspx - not working
http://site.com/old-folder/folder2/page1.aspx - not working
but in browser just /folder/folder2/page1.aspx show a valid page other links redirect users to 404 page that configured in umbraco config file.
Have you considered using the UrlRewriting module to get this working. You could add a new rule similar to the following:
<add name="page1rewrite"
virtualUrl="^~/en/folder/folder2/page1.aspx"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/folder/folder2/page2.aspx"
ignoreCase="true" />
This could be further improved depending on your exact requirements but you could it you wanted rewrite all urls ~/en/folder/folder2/ to the new location.
An alternative option would be to use the umbracoUrlAlias document type property.
I am trying to learn how to get Jasper running from within a grails app using the jasper plugin. On the plugin directory page [ http://grails.org/plugin/jasper ] there is a fairly in-depth tutorial. Which is supposed to show you how to extend a 'racetrack' example to use the jasper plugin. The problem I'm finding is that since the 'registrations.jrxml' is not shown on the tutorial, nor does it come with the source download of the plugin -- its impossible for me to figure out how to setup a jrxml file to work with data being sent to it from grails.
Right now, my application's controller is sending an ArrayList of HashMaps back to the view, which are then turned into html tables using "g:each". It's not a simple representation of a domain, the HashMaps are constructed from several different datasources. I need to also get this data exported through Jasper to an XLS file. Right now I can send the jrxml the ArrayList as a parameter, but I am going nowhere when it comes to correlating each member of the List (a Row) to a Detail in the jrxml.
So for the simplest case say I have a controller that provides a view with an ArrayList of Strings
def index = {
def people = ["Donald", "Richard", "Raymond", "Samir", "Cyrus"]
[people: people, guy: "Frank"]
}
and a view that passes the ArrayList to Jasper as a parameter.
<g:jasperReport format="PDF" jasper="don2" name="Don Report">
<input type="hidden" name="name" value="${guy}"/>
<input type="hidden" name="list" value="${people}"/>
</g:jasperReport>
What would I need to do in a jrxml to make use of the ArrayList as my datasource?
Don
You need JRBeanCollectionDataSource. Construct that in a controller (or in a custom tag of yours). You can't do it directly in the gsp.