Make your custom Renderosity product icons open their product web pages & readme files
In my ongoing migration to DS 4.9 I discovered you can make DS open a non-DAZ product web page when you click on the product icon. Like many others, I have a lot of Renderosity content and create my own products in DS for them. I have always wanted to be able to click on a non-DAZ product icon and go to the product's web page, just like with DAZ products. Well, in 4.9 you can. You just need to follow a consistent product Token naming convention and make a couple of simple code changes to the default.dsa script that DS prompts to show you when you click on a non-DAZ product icon.
When prompted, if you click on the "Product URL" button for a non-DAZ product, nothing happens. If you click on "Script Example" it opens the File Explorer to the "stores" folder.
Now, my coding skills are a little rusty, and there are many ways to code this but here is what I did.
1) First make sure you have a consistent product Token naming convention for your Renderosity products. I use Renderosity nn, where nn is the product id number that you see at the end of the Renderosiy product URL.
2) Open the default.dsa file in a text editor (I use EditPad Lite).
3) I made two changes to the script. The first was to eliminate the pop-up question box, the second was to check for an empty store URL and create a new Renderosity URL in its place.
First, change the code at the end of function begin as follows (just cut and paste the red text, be sure not to forget the begining and ending comments around the MessageBox code):
...
// If the control keyboard modifier is pressed
if( g_bControlPressed ){
// Append input JSON data
sMessage += sJSON;
}
// Commented out the question message box code and just called showDatabasePageURL
showDatabasePageURL( sProductToken );// Prompt the user and respond to choice
/*
switch( MessageBox.question( sMessage, sProductToken, sProduct, sExample, sCancel ) ){
case 0:
showDatabasePageURL( sProductToken );
break;
case 1:
showURL( "file:///" + g_oFile.path() );
break;
default:
case 2:
break;
}
*/
Next add the following code to function getDatabasePageURL. Just copy and paste the red text at the location shown. Make sure to include the Renderosity URL even though it's not showing up red.
...
// Get the values
sStoreURL = g_oInfo[ sStoreURL ];
sStoreToken = g_oInfo[ sStoreToken ];// New code to return the Renderosity product URL
// Assumes your product Token is named: "Renderosity nn", where nn is the Renderosity product ID
if (sStoreURL.isEmpty()){
// assume it's Renderosity
var sRenderosityURL = "https://www.renderosity.com/mod/bcs/?ViewProduct=";
sRenderosityURL += sProductToken.substring(12);
return sRenderosityURL;
}// Return the URL
return sStoreURL.replace( sStoreToken, sProductToken );
Hopefully it's okay to post this code. It works like a charm and is a nice new feature for us content management nuts. I have also observed that DAZ products do not appear to use this script.
Comments
Hi I see, your way is good enough to modify scritpt for each products.
On the other hand, I prefer to record each store id on data base first , with the script DAZ offered as DAZ script sample, after that I just need to keep same rule to set "Token" when I make the product meta data for the store, then it can show product page of the store correctly. . I feel, you can easy modify it.then add each store, on your data base.
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/metadata/add_store_id/start
you se,, there is "DB_Add_Store_Id.dsa", at first I copy it and rename like that "DB_Add_renXXX_Store_Id.dsa" for shop renXXX
I may suggest you make all add_sotre_id.dsa with each shop name which you hope to add sotre id in DB. then modify the copied one..
I tweak only last codes of above linked script for rendXXX store.
then when I make product meta-data of store "rendxxx" ,, I set meta-data token as "@", to show the linked page by click !"product"
eg,, one of product of RendXXX, I needed to set token like that, "productname/112491/"
(I can not show every detail,, but if you like tweak DAZ script,, you may easy find how to set correctly url and meta-data token for each store ID , I do not think my way is best (you can make it more smart I believe) , but I do not hope to learn deep daz script,, then it is good enough for me at current. and can not recommend for all)
=========
and for those who often mss somothing as same as me, may need this script url often. it can remove "your added store" from DB, you know, you just need to set last "My Store" correctly.
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/metadata/remove_store_id/start
to check which store ID are currently recorded,
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/metadata/store_info/start
of course, try by your self with your responsiblity.
and I know,, if each contents store change their way to show procut URL,, we need to modify and re-assign store ID,,the worst case, I may need to re-make all product meta-data token of the store.. I just hope each shop keep curent rule.
kitakoredaz, thanks for the tip on the script to add a store id. I didn't know you could do that. Creating a new store id first is a much better solution as it eliminates the code hack in the getDatabasePageURL function I posted above. Plus it easily allows for products from other stores besides Renderosity. I'm going to use this technique so thanks again.
However, I notice in your screen grab it is still showing the pop-up question. If you want to eliminate that dialog box then just make the change to the begin function in default.dsa that I posted above.
My only other recommendation is you can simplify the Token to just the product id number for Renderosity products. If you change the string in your DB_Add_renXXX_Store_Id.dsa script to "https://www.renderosity.com/mod/bcs/?ViewProduct=@", then you just need the product's numeric id to be the Token, just like DAZ does for its products. This has the added benefit of making the product file name shorter when you export it by eliminating duplicate product name text.
Using your example:
Token: enigma-redux-g3f-g2/112491/ becomes simply 112491
Product support filename: Renderosity_enigma-redux-g3f-g2f_112491__EnigmaRedux_G3F.dsa becomes Renderosity_112491__EnigmaRedux_G3F.dsa
As you've already implemented your solution I would leave it alone but for others who might want to do this it requires much less typing, especially if you have a lot of Renderosity products. Sorry to the mods for having a brief script discussion in this section.
Hi thanks , I did not know how to modify the sample script (I knew , I could modify default.script and may use to show read-me )
ntill look this topic, then this topic is very useful for me to know the way clear .
I was thinking,, if the default.dsa can use as link of each read-me in local PC, ,with key words,, if I gather all read-me files and save directories,, with token,, too.
as asme as another hiper-link.dsa,,, maybe try when I hope so. then if I made eachshop.dsa as same as sample,, and rename it,,how I can access it?
I do not know. which code or script actually call the "default" and "sample" script,, , with event mouse click,,, or it need another programing knowledge?
and yes About token,,and long product.dsx name,, I felt l I could modify it, but I ddi not know, those CGI or PHP keywords clear.
I like to keep same rule for all shope,, but I could not find good way,,, may try it. thank you. (eg,, about share CG,, how you make it ?
I hope to know,,, more smart way,, at current,, my share CG package .dsa name is teribbly long ^^;)
You keep coming up with great ideas. I started to create individual scripts to launch the readme files on my PC in a text editor but that was tedious and so I put that task on the back burner.
So thanks for the programming assignment. After some thinking, here is a solution for Renderosity content. While I do have content from other sources besides Renderosity I have not felt the need to ever go to those sites for reference, including sharecg. On the other hand, Renderosity product pages are very good and include links to the readme file, And speaking of links, why not just link to the readme file on the Renderosity web site? Forget about trying to open readme files on your PC, they're not named consistently and are not all in the same location.
So here's my solution:
1) First add a Renderosity store ID using the DAZ script you mentioned (DB_Add_Store_Id.dsa). Just change the last line of the script as indicated in red and run it once. Note that this requires your product Token to be just the numeric Renderosity product ID.
2) Change the default.dsa script located in: C:\Program Files\DAZ 3D\DAZStudio4 Public Build\resources\stores to make the following changes in red to the question box code in the begin function:
You will now have a question box come up that will allow you to choose either the Renderosity product page or the product's ReadMe file (on the Renderosity site) when you click on your custom Renderosity product icon.
Rather than editing the /resources/stores/default.dsa script, which is part of DS and will be replaced next time an update is installed, save your modified copy as StoreID.dsa in the same folder - there's already a DAZ 3D.dse there for Daz, you are adding a companion for Renderoisty (or whatever). That will be safe during DS updates.
Ah, good to know!
So to be clear, if I define a new store ID using the DB_Add_Store_Id.dsa script and call it "Renderosity", like I did above, then DS will look for a script named "Renderosity.dsa" in the /resources/stores folder, and if that file doesn't exist then it will use "default.dsa"?
Yes.
Good to know,, thanks
Hello,
After creating an asset with metadata installable with DIM, I would like if I go to the product page and click on the product it directs me to its URL page.
For example, for a Renderosity product,
I copied the file 'default.dsa' and renamed it to 'Renderosity.dsa' and then added the lines:
//*****************************************************************
//Modification made
// on 10/31/2023
//*****************************************************************
// New code to return the URL of the Renderosity product
if (sStoreURL.isEmpty()){
// if it's a Renderosity product
var sRenderosityURL = "https://www.renderosity.com/mod/bcs/?ViewProduct=";
sRenderosityURL += sProductToken.substring(12);
return sRenderosityURL;
}
Which I placed after
// Get the values
sStoreURL = g_oInfo[ sStoreURL ];
sStoreToken = g_oInfo[ sStoreToken ];
But it doesn't work, I still see the dialog box and nothing happens when I click on the 'Product URL' button, even though it has correctly identified the product as can be seen in the first part of the dialog box text and apparently uses my 'Renderosity.dsa' file. See screenshot.
I've attached my 'Renderosity.dsa' file
I'm running Windows 11 and DAZ version 4.21. My web browser is Opera.
Can you help me?
Translated with DeepL
For your reference...
I'm not sure which script that is (you should give a link) but http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/metadata/add_store_id/start will let you add stores as needed - I have one for Renderosity, one for commercial use freebies, and one for non-commerical freebies.
Haven't looked at this in a while. With the store_id properly set using DB_Add_Store_Id.dsa, the default script opens the product's page (i.e., Renderosity), but it always opens the dialog confirming the choice first. If I make a copy of the default.dsa script with the same name as the store ID, it still works, but nothing is actually changed in the script, and I still get the confirmation dialog, with the "Rederosity.dsa" script mentioned in the text instead of "default.dsa".
What, if anything, needs to be changed in the script to avoid the prompt? I don't see the need for a separate named script if I can use the default.dsa and a properly formed Store ID and Token.
Comment out lines 236-251 (block for
else if( bHasProductToken )
) and addnResult = 0
in their place.Excellent. Works like a charm. Thanks so much.
The default.dsa (Script Example) is in here - C:\Program Files\DAZ 3D\DAZStudio4\resources\stores
crosswind Thank you very much. I modified the lines as you indicated in your example. It works perfectly.
I tried to do the same thing with Renderotica products.
I managed to do it by creating a token of the form 59274_Kim-For-G8F, but it gives me long names in support (Renderotica_59274_Kim-For-G8F_Kim_For_G8F).
I'd have to transform my Kim For G8F into _Kim-For-G8F directly in the dsa file, but I don't even know what language is used and I don't know much about programming.
For other stores like Forender, there aren't even SKUs and depending on the type of product, the paths aren't even the same. I think is not possible.
Translated with DeepL
Use the SKU number only and the URL in the following list for the store, and the site will auto redirect to the correct page
You're welcome !
Hmm... as for RE site, since the products there have tokens so it's still easy but just need some tricks..
1. You need to correctly install the product with at least Store ID, Token and Product Name. I always use Content Wizard to install 3rd-party products. So far so great! Let's use 68936 as an example, as screenshot 1 & 2
2. Modify the dsa file as screenshot 3. Done! (dsa file attached.) * Be noted that default url is : ".../sku/68936_Security-Device", but ".../sku/68936_Security Device" or ".../sku/68936_Security%20Device" can also be resolved.
As for the store with no SKU# or Token, like forender, you also can make it but cumbersome indeed, as their product URL is pretty stupid... I give you a character example, see screenshot 4 & 5. Then you modify the code accordingly. But there're different 'categorie' in URL (character, weapon, etc. ), you have to read category from cms and modify code a lot... Really suggest you a no-go... I myself just built the links for Daz3D and Rendo which is enough for me.
Can the Store URL be modified? Probably needs some scripting... If you don't quite get it right, you can't add it again, it must be deleted before trying a new definition. Deleting the store if it has been applied to any Product will kill the corresponding metadata (it can be re-imported from metadata files, if they exist, as Vendor data only). The assets probably went into LOCAL USER. I suppose I could have re-created the Product from the Content Directory, but it didn't occur to me at the time. Any customization will be lost unless you have a backup of User data. I only had a few using an early attempt that did not work, so only took a few minutes to recover.
I know it's only a placeholder, but even so the renderotica link needed to be broken - I have added spaces, which should bee asy to remove.
Thanks for fixing this, I forget the forum autogenerates links from text
@crosswind
Use the URL
https://www.forender.com/market/product/@-
(note the hyphen) and you can use the FoRender product ID as the Token, dropping the category and product name altogether. Same with Renderotica, but with an underscore instead. Both sites drop everything after the hyphen/underscore when looking up the ID.Ahh... I didn't try that, then it'll be much easier for @Tiberium30500 Daz+Rendor are fine enough for me, LOL. Thank you for the reminder !
@Tiberium30500
Since such a URL : https://www.forender.com/market/product/1946-rui-tachibana-for-g8f works, it turns out to be much doable, even easier than RE. Pls feel free to go for a try.
I don't recall a way to do this with scripting. Should probably file a feature request because some site will no doubt change the URL needed someday. It can be done with a SQL query, but I believe that is only available for plugins in DS. The easiest way to do this would therefore be from outside of DS (with DS open so the CMS is available). On Windows, I would do this from the command line
I suppose the script to add a store could prompt to overwrite the existing definition if it exists, instead of just refusing the action. Feature request TODO...
With script, we may collect and check the existing stores in cms and use assetMgr.createStore() to add SiteID and URL, there should be no problem. I always use Content Wizard and Navicat.
a huge thank you to @crosswind and Omniflux.
So far I've been able to do Renderotica, Deviant Art and Forender and everything seems to be working perfectly.
Translated with DeepL
That's great ! You're welcome
Direct access to the database is not supported, it all has to be done through calls like those in the scripting engine - the actual backend has changed on occasion, with the access functions rewritten to still work with the new system.