Differences

This shows you the differences between two versions of the page.

Link to this comparison view

app_developer:application_urls [2019/06/05 02:57] (current)
Line 1: Line 1:
 +====== Splint Application URLs and Helper Functions ======
  
 +Because the Splint AppEngine is partially like a Code Igniter application within a Code Igniter application,​ there will be issues with URLs if not handled properly.\\
 +
 +This issue is been taken  care of by the ''​AppRouter''​ class of the Splint platform package and the ''​MY_Uri.php''​ file copied to your ''​core''​ folder on the installation of any package using the Splint terminal tool.\\
 +
 +The ''​MY_Uri.php''​ script, exposes two public variables, ''​$appsegments''​ and ''​$apprsegments''​. You guessed right, these variables hold the URI array of thee ''​$segment''​ starting from segment 3.\\
 +
 +This means that the value of ''​$segment[3]''​ is the same as ''​$appsegment[1]''​.\\
 +
 +Just as you have the ''​site_url''​ and the ''​base_url''​ functions as part of the URL Helper when writing codes within Code Igniter, the Splint AppEngine has the ''​app_url''​ and the ''​asset_url''​ function. They are automatically loaded as well as the URL Helper as they depend on functions of the URL Helper to work.
 +
 +===== app_url($uri) =====
 +
 +This function takes a URI and appends in front of it, the full URL of your website followed by the URI of the app calling Controller method.
 +
 +==== Example ====
 +
 +<code php>
 +echo app_url("​app_controller/​app_method"​);​
 +
 +// Output: https://​example.com/​CallingController/​callingMethod/​app_controller/​app_method
 +</​code>​
 +
 +===== asset_url($resource) =====
 +
 +All Splint application packages built containing an ''​assets''​ folder will have the contents of that folder moved to ''​splint-assets/<​vendor>/<​application_name>''​ on installation on an end-user'​s Code Igniter distribution on installation using the Splint terminal tool.\\
 +
 +The ''​asset_url''​ function help provide a URL relative to this new path by appending in fron of the argument ''​$resource''​ provided, the full Splint assets URL.
 +
 +==== Example ====
 +
 +To load a resource, say ''​logo.png''​ from an application package identified by ''​marcus/​cookies'',​ one would use the ''​asset_url''​ function as show below to get it's URL.
 +
 +<code php>
 +echo asset_url("​logo.png"​);​
 +
 +// Output: https://​example.com/​splint-assets/​marcus/​cookies/​logo.png
 +</​code>​
 +
 +===== NEXT =====
 +
 +[[app_developer:​loading_application_resources_within_the_application|Loading Splint Application Resources]] => \\
 +
 +===== PREVIOUS =====
 +
 +<= [[app_developer:​splint_app_controller_class|SplintAppController Class]]\\