Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Shannon 148 posts 171 karma points
    May 27, 2011 @ 17:01
    Shannon
    0

    How hard is it to use SQL commands in XSLT

    I have two XSLT files I use for recording pageviews in Blog4Umbraco:

    1) The first one calculates the number of papgeviews and republishes the document

    http://www.pastie.org/private/zl32w7snrrahrooy4jiuw

    2) The second one calulates which articles has the most pageviews within a certain period of time and displays them in a format for the Nivo Slider to read and display

    http://www.pastie.org/private/vykewtun5mumnrxymlbia

    I would like to change this to use the SQL database to record the Node, date published, and the pageview count. Currently the above xslt adds about 2 seconds to the rendering time. Hopefully moving to SQL will cut that time down a bit..:-)

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    May 27, 2011 @ 23:10
    Jan Skovgaard
    0

    Hi Shannon

    I think this package http://our.umbraco.org/projects/developer-tools/a-sqlhelper-for-xslt could be something for you. Unfortunately I have not had the time to create an actual package with this extension yet (Shame on me! Hope that I can manage to throw it up on sunday) - But you should be able to download the source and compile it for yourself.

    It makes it possible for you to fetch data easily from a stored procedure or write to a stored procedure from within your XSLT file.

    When you fetch data it's returned as XML, which you can match the way you want to :-)

    I hope that this helps even though I realise I need to describe this better and provide you with some usefull examples...I will keep you posted once the package is up and there are some example XSLT files.

    /Jan

  • Shannon 148 posts 171 karma points
    May 27, 2011 @ 23:38
    Shannon
    0

    I looked at that but I don't think it would work for me. I need to INSERT values to the database and well as SELECT. This only allows me to SELECT from what I can see.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    May 27, 2011 @ 23:44
    Jan Skovgaard
    0

    Hi Shannon

    If you have created a stored procedure that inserts values into the database you should be able to achieve it with this package as well.

    I will keep you posted once I have managed to get the samples in place on sunday.

    Stay tuned! :-)

    /Jan

  • Shannon 148 posts 171 karma points
    May 30, 2011 @ 18:11
    Shannon
    0

    And Sunday comes and goes..:-)

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jun 05, 2011 @ 16:03
    Jan Skovgaard
    0

    Hi Shannon

    Yes it indeed does...I'm sorry for my very late reply. Things just got crazy unfortunately.

    But know there have been made packages for the project with the code snippets found in the documentation.

    In order to be able to insert values into the database using the SqlHelper, you should be as mentioned be able to create a stored procedure, which you feed with the proper arguments from within your XSLT file.

    Hope this helps. (If you have not found another way around it already)

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft