Hi All,
I am developing a classified ads extension for umbraco, which I will package and release to the community when done. The idea is that it is 100% umbraco - for instance, no custom database tables are required. I achieve this by using a document type with the information I need such as price, location, title, content etc and search through that.
Now, I had a ASP.NET usercontrol handling the search, and search results. This worked well, but the style of the results are fixed, and only modified via the source. As I want to release this to the community, that isn't acceptable.
My next version used and ASP.NET usercontrol to make a themeable search panel (keywords, min/max price) and the "Search" button sets all of the search terms into session variables. The control would then refresh the page and an XSLT "search" macro would grab variables from the session object and conduct the search.
This works well, but suffers two problems:
* The keywords search syntax is limited to phrases, as I could only use the XSLT "contains" function against the description and title.
* Unable to use AJAX to load the results without a page refresh.
So, the desired effect is to be able to customize the search results of an ASCX macro. Ideally, the ASCX would do the search, find relevant nodes and call an XSLT macro for each result. The XSLT macro would contain the code for a single search result.
The other way is extensive CSS theming, but what if someone else wanted to add a property to the document type? They would need to modify the search control to display that info. Calling an XSLT macro per result would allow anyone to do that themselves.
Have you ever used the old umbSearch package? Basically it is a search control (that utilises Lucene.NET) and it can format the search results as part of the user control rendering or, alternatively, there is a mode whereby it generates XML on the fly and then references an XSLT style-sheet and uses that to transform the results. The latter method seems to me a good idea - it allows you to use the power of .NET to generate results in XML and then use the flexibility of XSLT to style those results.
Diplo - that was a stroke of genius! It works perfectly.
I promise to stick to my word. The (very messy) source code will be made public once my wife's site is up and running. Until then, feel free to ask any questions...
Hey, I'm really glad that worked - excellent! Though I can't take credit for the idea - just happy to help. Keep us updated when you release the package, it sounds interesting and useful.
Hi! I have ascx files as macros and I have a few tables placed together with the databases of Umbraco on a server. I need a path string to connect to the database: I tried with the path of SQL Management Studio, but it doesn't seem to work. I tried "Data Source=(local);Integrated Security=True" and "data source=127.0.0.1;Trusted_Connection=yes".
Nothing works. Any suggestons will be highly appreciated!
If this is a remote SQL server, you should replace "(local)" by the actual IP address of that SQL server. My guess is that you should also pass the user name and password of the sql user configured to access your database.
In that case, if your data is stored in the database "MyDatabase", you should have the following entry in your web.config file in order for Umbraco to access the data:
If you then have custom tables you want to use from your custom controls, you can probably create your connections by accessing that same key via the default .Net ConfigurationManager object, or create a separate connection string entry in the web.config. Just put the following code somewhere under the main <configuration> node of your web.config file:
You can then get the connection string in your code by doing the following (or something similar to):
var myConnection = newSqlConnection(ConfigurationManager.ConnectionStrings["MyCustomConnectionString"].ConnectionString)
I personnally create a separate connection string entry, so that I clearly separate what is Umbraco related and custom development related. Plus, this allows you to very easily put your custom tables on a separate database later on if needed, without needing to change any of your code regarding database connectivity.
It works perfectly when I access the database from Visual Web Developer or SQL Server Management Studio but it doesn't work inside the Umbraco installation.
Anyway thank you once again a lot for your answer, you probally saved my day. I look forward to try it tomorrow!
Strange indeed. Did you specify the data provider explicitely? How did you create your actual connection using that "myString" value? Maybe Visual Web Dev and SQL Server Mgt Studio take the SQL provider "by default", unlike the place you installed your Umbraco site (although this seems unlikely to me)??
Anyway, I hope the web.config solution will indeed solve your problem. Let me know :-)
Templating ASCX Usercontrol Search Results
Hi All,
I am developing a classified ads extension for umbraco, which I will package and release to the community when done. The idea is that it is 100% umbraco - for instance, no custom database tables are required. I achieve this by using a document type with the information I need such as price, location, title, content etc and search through that.
Now, I had a ASP.NET usercontrol handling the search, and search results. This worked well, but the style of the results are fixed, and only modified via the source. As I want to release this to the community, that isn't acceptable.
My next version used and ASP.NET usercontrol to make a themeable search panel (keywords, min/max price) and the "Search" button sets all of the search terms into session variables. The control would then refresh the page and an XSLT "search" macro would grab variables from the session object and conduct the search.
This works well, but suffers two problems:
* The keywords search syntax is limited to phrases, as I could only use the XSLT "contains" function against the description and title.
* Unable to use AJAX to load the results without a page refresh.
So, the desired effect is to be able to customize the search results of an ASCX macro. Ideally, the ASCX would do the search, find relevant nodes and call an XSLT macro for each result. The XSLT macro would contain the code for a single search result.
The other way is extensive CSS theming, but what if someone else wanted to add a property to the document type? They would need to modify the search control to display that info. Calling an XSLT macro per result would allow anyone to do that themselves.
Ideas anyone?!
Thanks
Gaz
bump?
Last try...Any ideas?!
Thanks
Have you ever used the old umbSearch package? Basically it is a search control (that utilises Lucene.NET) and it can format the search results as part of the user control rendering or, alternatively, there is a mode whereby it generates XML on the fly and then references an XSLT style-sheet and uses that to transform the results. The latter method seems to me a good idea - it allows you to use the power of .NET to generate results in XML and then use the flexibility of XSLT to style those results.
It may be worth downloading the source code from http://www.codeplex.com/umbracoext/SourceControl/ListDownloadableCommits.aspx
(Note the code doesn't work with Umbraco V4 "as is" but it may give you some ideas. Just look for the umbSearch project).
Great idea! I knew there would be a solution out there. I'll give it a blast this week and post back.
Thanks for the Heads Up!
Gaz
Diplo - that was a stroke of genius! It works perfectly.
I promise to stick to my word. The (very messy) source code will be made public once my wife's site is up and running. Until then, feel free to ask any questions...
Thanks again,
Gaz
Hey, I'm really glad that worked - excellent! Though I can't take credit for the idea - just happy to help. Keep us updated when you release the package, it sounds interesting and useful.
Hi! I have ascx files as macros and I have a few tables placed together with the databases of Umbraco on a server. I need a path string to connect to the database: I tried with the path of SQL Management Studio, but it doesn't seem to work. I tried "Data Source=(local);Integrated Security=True" and "data source=127.0.0.1;Trusted_Connection=yes".
Nothing works. Any suggestons will be highly appreciated!
Hi Lars,
If this is a remote SQL server, you should replace "(local)" by the actual IP address of that SQL server. My guess is that you should also pass the user name and password of the sql user configured to access your database.
Cheers,
Michael.
YES. Someone answered me.
But what do you mean precisely, I would like to understand it all.
Say that the IP of the server is 123.45.678.90 and the login is "Mylogin" and the password is "Mypass".
"Data Source=123.45.678.90; ......" instead of (local)?
Thank you so far, Michael
Regards, Lars
Hi Lars,
In that case, if your data is stored in the database "MyDatabase", you should have the following entry in your web.config file in order for Umbraco to access the data:
If you then have custom tables you want to use from your custom controls, you can probably create your connections by accessing that same key via the default .Net ConfigurationManager object, or create a separate connection string entry in the web.config. Just put the following code somewhere under the main <configuration> node of your web.config file:
You can then get the connection string in your code by doing the following (or something similar to):
I personnally create a separate connection string entry, so that I clearly separate what is Umbraco related and custom development related. Plus, this allows you to very easily put your custom tables on a separate database later on if needed, without needing to change any of your code regarding database connectivity.
Cheers,
Michael.
Hello Michael.
I prefer clearly a seperate string. The strange thing is that I tried with a string
string myString = "Data Source=www.myweb.com;Initial Catalog=my_catalog;Persist Security Info=True;User ID=myUser;Password=myPassword";
It works perfectly when I access the database from Visual Web Developer or SQL Server Management Studio but it doesn't work inside the Umbraco installation.
Anyway thank you once again a lot for your answer, you probally saved my day. I look forward to try it tomorrow!
Regards
Lars
Hello Lars,
Strange indeed. Did you specify the data provider explicitely? How did you create your actual connection using that "myString" value? Maybe Visual Web Dev and SQL Server Mgt Studio take the SQL provider "by default", unlike the place you installed your Umbraco site (although this seems unlikely to me)??
Anyway, I hope the web.config solution will indeed solve your problem. Let me know :-)
Cheers,
Michael.
is working on a reply...