Recent Topics

1 Apr 11, 2016 05:40    

Convenient for Chinese webmasters to batch import regional information. The way as follows:

  1. Unzip the file Import_China_Regional.zip;
  2. Import the file tm_location.sql into b2 database;
  3. Put the file import_china_regional.php into the web root dir of b2, then access to the url as like : http://your-b2-web-url/import_china_regional.php
  4. [Importment!]: Delete the file import_china_regional.php from webroot.

That's all.

NOTE: This code is not optimized and only for users who know a bit of PHP and MYSQL (understand the code by the comments, it's really simple and easy). Please see the comments of the file 'import_china_regional' to get more info .

3 Apr 11, 2016 07:37

Excellent, thanks for this contribution @haharen ! I almost immediately thought on use it (as it) to import regions of other countries :D

Actually, there is an existing import tool but it's only for cities (http://b2evolution.net/man/cities-import), so extending that feature to let admins import the whole structure in a single action, would be great. Would you like to help us to convert this into a plugin?

Please see this repository: https://github.com/mgsolipa/b2evolution-import_regions_plugin (NOTE: I created it in my own GitHub account, but I think we can move it to the b2evolution's account when it's ready). It's just the plugin's skeleton, so a blank canvas to work on.

The main idea is to use the AdminToolPayload and AdminToolAction events to add a maintenance tool (maybe it should be an import tool) that let the user upload a CSV file to read the regions from it (instead of the database table as you initially implemented).

The second idea is to re-use your code in combination with the own b2evolution's API methods to control the regions, sub-regions and cities records. This way we can take advance of such features as user access control, duplicity control, etc.

I added a small TODO list to the README file, so we can develop this together. What do you think?

Thank you.

4 Apr 11, 2016 07:41

In addition to above, along with the plugin itself we can add single CSV files by country, so site admins may download what they want and import to their sites, as we currently do with localisation files.

I can think on China, Spain and Venezuela as a starting point.

@fplanque what do you think?

5 Apr 11, 2016 11:00

@mgsolipa
Thank you for your affirmation, I am glad to do this indeed, it's my pleasure. However my ability of programming is relatively weak, so I have to need some time replenish programming knowledge. And if I make any mistake, please correct me.Thanks!


Form is loading...