Question

Photo of Kenneth Roach

0

How can I implement my own version of SampleData.ascx.cs?

I'm looking at using the SampleData import mechanism as a way of importing our data.  My import needs are simple: Person and Family only.  I have a spreadsheet of Person data, from which I can create an xml file with Family and Person data, as per the Sample Data.  (At this stage I don't care about Groups nor Relationships, nor photos.)

The SampleData.ascx.cs file (in the directory ../Rock/RockWeb/Blocks/Examples) which I understand is used to import and process the sample data, does not cater for some Person attributes, e.g. Title.

In addition, I may have other Defined Value types not included in the default list of titles.  For example, the title 'Ps.' for 'Pastor.'

I understand it is possible for me to edit the SampleData.ascx.cs doc, and add in lines to cater for these attributes (Title) and my uniquely defined values ('Ps.').

But how would I then implement my new version of SampleData.ascx.cs for the data I want to load?  (I'm not running my own version of the Rock software.)

I probably need to know if I am going to be able to do this before I go too far down the road of creating my own version of SampleData.ascx.cs.

Two ideas:

1) Perhaps someone could modify the existing SampleData.ascx.cs file so that it caters for ALL the currently defined Person and Family attributes, so we don't all have to do this.

2) Perhaps, in addition to being allowed to point to a different sample data file to upload, we could also be allowed to select our own version of the SampleData.ascx.cs file if we needed to use one different to the default one?

Installation
  • Photo of Nick Airdo

    1

    The way you could create your own version of a block would be to do the following... Using SampleData as the example:

    1. make a copy of the block and put it under the Plugins\com_yourDomain\your_Project_or_Category\SampleData.ascx (and SampleData.ascx.cs)
    2. change the "Inherits=" value in the *.ascx file to "RockWeb.Plugins.com_yourDomain.Project.SampleData"
    3. change the "namespace" value similarly to "RockWeb.Plugins.com_yourDomain.Project" (don't include SampleData at the end -- that's the class name)
    4. change the "[Category( )]" to something like "[Category( YourDomain > SampleData )]"
    5. make other custom changes as needed
    6. *after* doing that
      1. visit the Rock page where you want to include that block and click the Page Zones icon in the admin bar.
      2. slide out the Zone Block menu and click the icon.
      3. use the (+) icon to add your new block to the page. It should be listed under the YourDomain section

    Note: some_value indicates to use your own domain name, organization name or project name, etc.