advance route, about ids in item URLs

More
8 years 4 months ago - 8 years 4 months ago #58591 by MikeM
Hello! I have some question
1. How can i create an alias for item without "-"
like
mysite.com/category/999itemalias (not mysite.com/category/999-itemalias)

2. How can i do that number in example above - is count value of current item in category?

3. How can i create that number in example above i can take some variable as i need?
Last edit: 8 years 4 months ago by ggppdk.

Please Log in or Create an account to join the conversation.

More
8 years 4 months ago - 8 years 4 months ago #58594 by ggppdk
Hello

1. the '-' from URLs can not be removed,
the item urls are
- either like you described
- or the use the menu alias if there is a menu item directly pointing to them (single item menu item)

2. the number is the ID of the item
so if you are inside an item view:
Code:
$app = JFactory::getApplication(); $jinput = $app->input; $FCitemID = $jinput->get('id', 0, 'int');

or inside template file "item(_html5).php",
or inside template file "category_items(_html5).php", (inside the LOOP of items)
use:
Code:
echo $item->id;


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...
Last edit: 8 years 4 months ago by ggppdk.

Please Log in or Create an account to join the conversation.

More
8 years 4 months ago - 8 years 4 months ago #58596 by MikeM
ggppdk, thank you for fast answer, but i mean some more

perhaps i create an bicycle :cheer: , but i try to create users profiles based on flexi (as try many people i see)

what i wanna create:
  1. -when user is register on site i add a code in register form code, that create FC item in category "users" ("profile")
  2. - this item i see like in post in ( www.flexicontent.org/forum/23-documentat...ial-media-sites.html )
  3. - this item generated with link like /users/user123, where user - constant prefix, 123 - user id ,
  4. in router something like (CB code)
Code:
$vars= array(); $count = count( $segments ); if ( $count > 0 ) { $vars['view'] = strtolower( $segments[0] ); switch ( $vars['view'] ) { case 'userprofile': if ( $count > 1 ) { $user = str_replace( array( ':', ',' ), array( '-', '.' ), $segments[1] ); if ( ! is_numeric( $user ) ) { $database = JFactory::getDBO(); $sql = 'SELECT' . $database->quoteName( 'id' ) . "\n FROM " . $database->quoteName( '#__users' ) . "\n WHERE " . $database->quoteName( 'username' ) . " = ". $database->Quote( rawurldecode( $user ) ); $database->setQuery( $sql, 0, 1 ); $user= (int) $database->loadResult(); if ( ! $user ) { $user = str_replace( array( ':', '_' ), array( '-', '.' ), $segments[1] ); $sql = 'SELECT' . $database->quoteName( 'id' ) . "\n FROM " . $database->quoteName( '#__users' ) . "\n WHERE " . $database->quoteName( 'username' ) . " = ". $database->Quote( $user ); $database->setQuery( $sql, 0, 1 ); $user = (int) $database->loadResult(); } } $vars['user'] = (int) $user; } break;


how make it work in FC ?
Last edit: 8 years 4 months ago by MikeM.

Please Log in or Create an account to join the conversation.

More
8 years 4 months ago #58601 by MikeM
ggppdk, it was very very cool if you added in flexicontent options in global configeration of component option:
"id fo category, that use as profiles category"
and its id then used in router.php like userlist and user in CB

i try do it myself, and if it done i put code here,
but my knowledge is too small((

Please Log in or Create an account to join the conversation.

More
8 years 4 months ago - 8 years 4 months ago #58603 by MikeM
i do my codemonkey experiment :cheer:
i add in router.php this code:
Code:
case FLEXI_ITEMVIEW: $mcid = @$menu->query['cid']; // not set returns null $cid = !isset($query['cid']) ? null : (int)$query['cid']; $mid = @$menu->query['id']; // not set returns null $id = !isset($query['id']) ? null : (int)$query['id']; if ( $mid == $id && $mview == FLEXI_ITEMVIEW ) { } else if ( $cid && ($mcid != $cid || $mview != 'category') ) { $segments[] = $query['cid']; $segments[] = @$query['id']; // suppress error since it may not be set e.g. for new item form } else { if ($add_item_sef_segment) { $segments[] = 'item'; } else { } if ($cid==23) {//id of my profiles category $segments[] = 'id'.$id; } else { $segments[] = @$query['id']; // suppress error since it may not be set e.g. for new item form } }

it looks cool - in category users(profiles) all items link look as site.com/users/id123
But i cant retranslate it in joomla. All this beauty link give an 404 error page.

I add in function FLEXIcontentParseRoute($segments) my monkey code:
Code:
// 'item' view if ($segments[0] == 'item' || $segments[0] == 'items') { $vars['view'] = FLEXI_ITEMVIEW; if ($count==2) {// no cid provided if (@$menu->query['view']=='category' && @$menu->query['cid']) { $vars['cid'] = (int)$menu->query['cid']; if ($vars['cid'] == 23){ //i think that here i check a category $vars['id'] = substr($segments[1], 2, 0); //i think that i delete "id", that i write above } else { $vars['id'] = $segments[1]; }} } else if ($count==3) { // also cid provided $vars['cid'] = $segments[1]; $vars['id'] = $segments[2]; } return $vars; }

But it not works. May be somebody tell me how and where i must put the code?
Last edit: 8 years 4 months ago by MikeM.

Please Log in or Create an account to join the conversation.

More
8 years 4 months ago #58629 by ggppdk
Hello

modifying the SEF URL code (hacking these files) is not supported,

- and these files will be overwritten on upgrade
and it is important to be able to upgrade FLEXIcontent ...

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.612 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline